';
- }
- if (0 < $rRow['member_id']) {
- $rOwner = "
';
- } else {
- $rOwner = $rRow['owner_name'];
- }
- if ($rRow['active_connections'] && $rRow['last_active']) {
- $rLastActive = "
';
- } else {
- if ($rRow['last_active']) {
- $rLastActive = date($rSettings['date_format'], $rRow['last_active']) . "
';
- } else {
- $rLastActive = 'Never';
- }
- }
- if (!isset(RequestManager::getAll()['no_url'])) {
- $rReturn['data'][] = array("
', $rRow['stb_type'], $rOwner, $rStatus, $rActive, $rTrial, $rExpDate, $rLastActive, $rButtons);
- } else {
- $rReturn['data'][] = array($rRow['mag_id'], $rRow['username'], $rRow['mac'], $rRow['stb_type'], $rRow['owner_name'], $rStatus, $rActive, $rTrial, $rExpDate, $rLastActive, $rButtons);
- }
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'enigmas') {
- if (Authorization::check('adv', 'manage_e2')) {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrder = array('`lines`.`id`', '`lines`.`username`', '`enigma2_devices`.`mac`', '`enigma2_devices`.`public_ip`', '`lines`.`member_id`', '`lines`.`enabled`', '`active_connections` > 0', '`lines`.`is_trial`', '`lines`.`exp_date`', '`active_connections` ' . $rOrderDirection . ', `last_activity`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 6) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines`.`username` LIKE ? OR `enigma2_devices`.`mac` LIKE ? OR `enigma2_devices`.`public_ip` LIKE ? OR FROM_UNIXTIME(`exp_date`) LIKE ? OR `lines`.`reseller_notes` LIKE ? OR `lines`.`admin_notes` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`lines`.`admin_enabled` = 1 AND `lines`.`enabled` = 1 AND (`lines`.`exp_date` IS NULL OR `lines`.`exp_date` > UNIX_TIMESTAMP()))';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`lines`.`enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '`lines`.`admin_enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`lines`.`exp_date` IS NOT NULL AND `lines`.`exp_date` <= UNIX_TIMESTAMP())';
- } else {
- if (RequestManager::getAll()['filter'] != 5) {
- } else {
- $rWhere[] = '`lines`.`is_trial` = 1';
- }
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'] ?? '')) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines` RIGHT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines`.`id`, `lines`.`username`, `lines`.`member_id`, `lines`.`last_activity`, `lines`.`last_activity_array`, `enigma2_devices`.`mac`, `enigma2_devices`.`public_ip`, `enigma2_devices`.`device_id`, `lines`.`exp_date`, `lines`.`admin_enabled`, `lines`.`enabled`, `lines`.`admin_notes`, `lines`.`reseller_notes`, `lines`.`max_connections`, `lines`.`is_trial`, (SELECT count(*) FROM `lines_live` WHERE `lines`.`id` = `lines_live`.`user_id` AND `hls_end` = 0) AS `active_connections` FROM `lines` RIGHT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rActivityIDs = $rLineInfo = $rLineIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['id']) {
- } else {
- $rLineIDs[] = intval($rRow['id']);
- $rLineInfo[intval($rRow['id'])] = array('owner_name' => null, 'stream_display_name' => null, 'stream_id' => null, 'last_active' => null);
- }
- if ($rLastInfo = json_decode($rRow['last_activity_array'], true)) {
- $rLineInfo[intval($rRow['id'])]['stream_id'] = $rLastInfo['stream_id'];
- $rLineInfo[intval($rRow['id'])]['last_active'] = $rLastInfo['date_end'];
- } else {
- if (!$rRow['last_activity']) {
- } else {
- $rActivityIDs[] = intval($rRow['last_activity']);
- }
- }
- }
- if (0 >= count($rLineIDs)) {
- } else {
- $db->query('SELECT `users`.`username`, `lines`.`id` FROM `users` LEFT JOIN `lines` ON `lines`.`member_id` = `users`.`id` WHERE `lines`.`id` IN (' . implode(',', $rLineIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rLineInfo[$rRow['id']]['owner_name'] = $rRow['username'];
- }
- if (SettingsManager::getAll()['redis_handler']) {
- $rConnectionCount = ConnectionTracker::getUserConnections($rLineIDs, true);
- $rConnectionMap = ConnectionTracker::getFirstConnection($rLineIDs);
- $rStreamIDs = array();
- foreach ($rConnectionMap as $rUserID => $rConnection) {
- if (in_array($rConnection['stream_id'], $rStreamIDs)) {
- } else {
- $rStreamIDs[] = intval($rConnection['stream_id']);
- }
- }
- $rStreamMap = array();
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `id`, `stream_display_name` FROM `streams` WHERE `id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rStreamMap[$rRow['id']] = $rRow['stream_display_name'];
- }
- }
- foreach ($rConnectionMap as $rUserID => $rConnection) {
- $rLineInfo[$rUserID]['stream_display_name'] = $rStreamMap[$rConnection['stream_id']];
- $rLineInfo[$rUserID]['stream_id'] = $rConnection['stream_id'];
- $rLineInfo[$rUserID]['last_active'] = $rConnection['date_start'];
- }
- unset($rConnectionMap);
- } else {
- $db->query('SELECT `lines_live`.`user_id`, `lines_live`.`stream_id`, `lines_live`.`date_start` AS `last_active`, `streams`.`stream_display_name` FROM `lines_live` LEFT JOIN `streams` ON `streams`.`id` = `lines_live`.`stream_id` INNER JOIN (SELECT `user_id`, MAX(`date_start`) AS `ts` FROM `lines_live` GROUP BY `user_id`) `maxt` ON (`lines_live`.`user_id` = `maxt`.`user_id` AND `lines_live`.`date_start` = `maxt`.`ts`) WHERE `lines_live`.`user_id` IN (' . implode(',', $rLineIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rLineInfo[$rRow['user_id']]['stream_display_name'] = $rRow['stream_display_name'];
- $rLineInfo[$rRow['user_id']]['stream_id'] = $rRow['stream_id'];
- $rLineInfo[$rRow['user_id']]['last_active'] = $rRow['last_active'];
- }
- }
- }
- if (0 >= count($rActivityIDs)) {
- } else {
- $db->query('SELECT `user_id`, `stream_id`, `date_end` AS `last_active` FROM `lines_activity` WHERE `activity_id` IN (' . implode(',', $rActivityIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- if (isset($rLineInfo[$rRow['user_id']]['stream_id'])) {
- } else {
- $rLineInfo[$rRow['user_id']]['stream_id'] = $rRow['stream_id'];
- $rLineInfo[$rRow['user_id']]['last_active'] = $rRow['last_active'];
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!isset($rLineInfo[$rRow['id']])) {
- } else {
- $rRow = array_merge($rRow, $rLineInfo[$rRow['id']]);
- }
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['active_connections'] = (isset($rConnectionCount[$rRow['id']]) ? $rConnectionCount[$rRow['id']] : 0);
- }
- if (!$rIsAPI) {
- if (!$rRow['id']) {
- $rStatus = '
';
- } else {
- if (!$rRow['admin_enabled']) {
- $rStatus = '
';
- } else {
- if (!$rRow['enabled']) {
- $rStatus = '
';
- } else {
- if ($rRow['exp_date'] && $rRow['exp_date'] < time()) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- }
- }
- }
- if (0 < $rRow['active_connections']) {
- $rActive = '
';
- }
- if ($rRow['is_trial']) {
- $rTrial = '
';
- }
- if ($rRow['exp_date']) {
- if ($rRow['exp_date'] < time()) {
- $rExpDate = '
';
- } else {
- $rExpDate = date($rSettings['date_format'], $rRow['exp_date']) . "
';
- }
- } else {
- $rExpDate = '∞';
- }
- if (Authorization::check('adv', 'live_connections')) {
- $rActiveConnections = '
';
- } else {
- $rActiveConnections = $rRow['active_connections'];
- }
- $rNotes = '';
- if (0 >= strlen($rRow['admin_notes'])) {
- } else {
- $rNotes .= $rRow['admin_notes'];
- }
- if (0 >= strlen($rRow['reseller_notes'])) {
- } else {
- if (strlen($rNotes) == 0) {
- } else {
- $rNotes .= "\n";
- }
- $rNotes .= $rRow['reseller_notes'];
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rNotes)) {
- } else {
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if (0 < strlen($rNotes)) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_user')) {
- } else {
- $rButtons .= '
";
- }
- if (!Authorization::check('adv', 'fingerprint')) {
- } else {
- if ($rRow['user_id'] && 0 < $rRow['active_connections']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
';
- }
- }
- if (!Authorization::check('adv', 'edit_e2')) {
- } else {
- $rButtons .= '
';
- if ($rRow['admin_enabled']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- if ($rRow['enabled'] == 1) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
";
- }
- $rButtons .= '
';
- }
- if (0 < $rRow['member_id']) {
- $rOwner = "
" . $rRow['owner_name'] . '';
- } else {
- $rOwner = $rRow['owner_name'];
- }
- if ($rRow['active_connections'] && $rRow['last_active']) {
- $rLastActive = "
" . $rRow['stream_display_name'] . "Online: " . TimeUtils::secondsToTime(time() - $rRow['last_active']) . '';
- } else {
- if ($rRow['last_active']) {
- $rLastActive = date($rSettings['date_format'], $rRow['last_active']) . "
" . date('H:i:s', $rRow['last_active']) . '';
- } else {
- $rLastActive = 'Never';
- }
- }
- if (!isset(RequestManager::getAll()['no_url'])) {
- $rReturn['data'][] = array("
" . $rRow['device_id'] . '', $rRow['username'], "
" . $rRow['mac'] . '', "
" . $rRow['public_ip'] . '', $rOwner, $rStatus, $rActive, $rTrial, $rExpDate, $rLastActive, $rButtons);
- } else {
- $rReturn['data'][] = array($rRow['device_id'], $rRow['username'], $rRow['mac'], $rRow['public_ip'], $rRow['owner_name'], $rStatus, $rActive, $rTrial, $rExpDate, $rLastActive, $rButtons);
- }
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'streams') {
- if (Authorization::check('adv', 'streams') || Authorization::check('adv', 'mass_edit_streams')) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_icon`', '`streams`.`stream_display_name`', '`streams_servers`.`current_source`', '`clients`', '`streams_servers`.`stream_started`', false, false, false, '`streams_servers`.`bitrate`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rCreated = isset(RequestManager::getAll()['created']);
- $rWhere = $rWhereV = array();
- if ($rCreated) {
- $rWhere[] = '`streams`.`type` = 3';
- } else {
- $rWhere[] = '`streams`.`type` = 1';
- }
- if (isset(RequestManager::getAll()['stream_id'])) {
- $rWhere[] = '`streams`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (!isset(RequestManager::getAll()['refresh'])) {
- } else {
- $rWhere = array('`streams`.`id` IN (' . implode(',', array_map('intval', explode(',', RequestManager::getAll()['refresh']))) . ')');
- $rWhereV = array();
- $rStart = 0;
- $rLimit = 1000;
- }
- if (strlen(RequestManager::getAll()['filter'] ?? '') > 0) {
- if (!$rCreated) {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`stream_status` = 0)';
- } elseif (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '((`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 1))';
- } elseif (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND `streams_servers`.`on_demand` = 0)';
- } elseif (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 2)';
- } elseif (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams_servers`.`on_demand` = 1';
- } elseif (RequestManager::getAll()['filter'] == 6) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } elseif (RequestManager::getAll()['filter'] == 7) {
- $rWhere[] = '`streams`.`tv_archive_server_id` > 0 AND `streams`.`tv_archive_duration` > 0';
- } elseif (RequestManager::getAll()['filter'] == 8) {
- if ($rSettings['streams_grouped'] == 1) {
- $rWhere[] = "(SELECT COUNT(*) AS `count` FROM `streams_logs` WHERE `streams_logs`.`action` = 'STREAM_FAILED' AND `streams_logs`.`date` >= UNIX_TIMESTAMP()-86400 AND `streams_logs`.`stream_id` = `streams`.`id`) > 144";
- } else {
- $rWhere[] = "(SELECT COUNT(*) AS `count` FROM `streams_logs` WHERE `streams_logs`.`action` = 'STREAM_FAILED' AND `streams_logs`.`date` >= UNIX_TIMESTAMP()-86400 AND `streams_logs`.`stream_id` = `streams`.`id` AND `streams_logs`.`server_id` = `streams_servers`.`server_id`) > 144";
- }
- } elseif (RequestManager::getAll()['filter'] == 9) {
- $rWhere[] = 'LENGTH(`streams`.`channel_id`) > 0';
- } elseif (RequestManager::getAll()['filter'] == 10) {
- $rWhere[] = '(`streams`.`channel_id` IS NULL OR LENGTH(`streams`.`channel_id`) = 0)';
- } elseif (RequestManager::getAll()['filter'] == 11) {
- $rWhere[] = '`streams`.`adaptive_link` IS NOT NULL';
- } elseif (RequestManager::getAll()['filter'] == 12) {
- $rWhere[] = '`streams`.`title_sync` IS NOT NULL';
- } elseif (RequestManager::getAll()['filter'] == 13) {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0)';
- } elseif (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = "(`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND (REPLACE(`streams_servers`.`cchannel_rsources`, '\\\\/', '/') = REPLACE(`streams`.`stream_source`, '\\\\/', '/'))";
- } elseif (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = "(REPLACE(`streams_servers`.`cchannel_rsources`, '\\\\/', '/') <> REPLACE(`streams`.`stream_source`, '\\\\/', '/'))";
- } elseif (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- if (strlen(RequestManager::getAll()['audio']) > 0) {
- if (RequestManager::getAll()['audio'] == -1) {
- $rWhere[] = '`streams_servers`.`audio_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`audio_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['audio'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['video'])) {
- } else {
- if (RequestManager::getAll()['video'] == -1) {
- $rWhere[] = '`streams_servers`.`video_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`video_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['video'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['resolution'])) {
- } else {
- $rWhere[] = '`streams_servers`.`resolution` = ?';
- $rWhereV[] = (intval(RequestManager::getAll()['resolution']) ?: null);
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rSettings['streams_grouped'] = 0;
- }
- if ($rSettings['streams_grouped'] == 1) {
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM (SELECT `id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id`) t1;';
- } else {
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- }
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rQuery = 'SELECT `streams`.`id`, `streams_servers`.`stream_id`, `streams`.`type`, `streams`.`stream_icon`, `streams`.`adaptive_link`, `streams`.`title_sync`, `streams_servers`.`cchannel_rsources`, `streams`.`stream_source`, `streams`.`stream_display_name`, `streams`.`tv_archive_duration`, `streams`.`tv_archive_server_id`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`cc_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams`.`epg_id`, `streams`.`channel_id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ', -`stream_started` DESC LIMIT ' . $rStart . ', ' . $rLimit . ';';
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`type`, `streams`.`stream_icon`, `streams`.`adaptive_link`, `streams`.`title_sync`, `streams_servers`.`cchannel_rsources`, `streams`.`stream_source`, `streams`.`stream_display_name`, `streams`.`tv_archive_duration`, `streams`.`tv_archive_server_id`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`cc_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams`.`epg_id`, `streams`.`channel_id`, `streams_servers`.`parent_id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- }
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rEPGIDs = $rFails = $rFailsPS = $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- if (!$rRow['channel_id'] || in_array("'" . $rRow['epg_id'] . '_' . $rRow['channel_id'] . "'", $rEPGIDs)) {
- } else {
- $rEPGIDs[] = "'" . $rRow['epg_id'] . '_' . str_replace("'", "\\'", $rRow['channel_id']) . "'";
- }
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped']) {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, true, true);
- } else {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, false, false);
- }
- }
- }
- if ($rCreated) {
- } else {
- $rTime = time();
- if (0 >= count($rStreamIDs)) {
- } else {
- $rQuery = "SELECT `stream_id`, `server_id`, COUNT(*) AS `fails`, MAX(`date`) AS `last` FROM `streams_logs` WHERE `action` IN ('STREAM_FAILED', 'STREAM_START_FAIL') AND `date` >= (UNIX_TIMESTAMP()-" . intval(($rSettings['fails_per_time'] ?: 86400)) . ') AND `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`, `server_id`;';
- $db->query($rQuery);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- $rFailsPS[$rRow['stream_id']][intval($rRow['server_id'])] = array($rRow['fails'], $rTime - $rRow['last']);
- $rFails[$rRow['stream_id']][0] += $rRow['fails'];
- if ($rFails[$rRow['stream_id']]['last'] >= $rTime - $rRow['last']) {
- } else {
- $rFails[$rRow['stream_id']][1] = $rTime - $rRow['last'];
- }
- }
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- } else {
- $rRow['clients'] = (count($rConnectionCount[$rRow['id']][$rRow['server_id']]) ?: 0);
- }
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (!(0 < $rRow['tv_archive_duration'] && 0 < $rRow['tv_archive_server_id'])) {
- } else {
- $rRow['stream_display_name'] .= "
";
- }
- if (0 >= count(json_decode($rRow['adaptive_link'], true))) {
- } else {
- $rRow['stream_display_name'] .= "
";
- }
- if (!$rRow['title_sync']) {
- } else {
- $rRow['stream_display_name'] .= "
";
- }
- $rStreamName = "
" . $rRow['stream_display_name'] . "
" . $rCategory . '';
- if ($rRow['server_name']) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- if (!($rSettings['streams_grouped'] && 1 < $rServerCount[$rRow['id']])) {
- } else {
- $rServerName .= "
';
- }
- if ($rServers[$rRow['server_id']]['last_status'] == 1) {
- } else {
- $rServerName .= "
Uptime cannot be confirmed.\" type='button' class='tooltip btn btn-danger btn-xs waves-effect waves-light'>
";
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- if (0 < intval($rRow['parent_id'])) {
- $rStreamSource = "
loop: " . strtolower(ServerRepository::getAll()[$rRow['parent_id']]['server_name']) . '';
- } else {
- $rStreamSource = "
" . strtolower(parse_url($rRow['current_source'])['host']) . '';
- }
- $rServerName .= $rStreamSource;
- if (0 >= intval($rRow['stream_started'])) {
- } else {
- $rSeconds = $rUptime = time() - intval($rRow['stream_started']);
- }
- $rActualStatus = 0;
- if ($rRow['server_id']) {
- if (!$rCreated) {
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- $rActualStatus = 1;
- } else {
- $rActualStatus = 7;
- }
- } else {
- $rActualStatus = 5;
- }
- } else {
- if ($rRow['monitor_pid']) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- if (intval($rRow['stream_status']) == 2) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 1;
- }
- } else {
- if ($rRow['stream_status'] == 0) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 3;
- }
- }
- } else {
- if (intval($rRow['on_demand']) == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 0;
- }
- }
- }
- } else {
- if ($rRow['monitor_pid']) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- if (intval($rRow['stream_status']) == 2) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 1;
- }
- } else {
- if ($rRow['stream_status'] == 0) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 3;
- }
- }
- } else {
- $rActualStatus = 0;
- }
- if (count(json_decode($rRow['cchannel_rsources'], true)) == count(json_decode($rRow['stream_source'], true)) || $rRow['parent_id']) {
- } else {
- $rActualStatus = 6;
- }
- }
- } else {
- if (intval($rRow['direct_source']) == 1) {
- $rActualStatus = 5;
- } else {
- $rActualStatus = -1;
- }
- }
- if ($rRow['server_id']) {
- } else {
- $rRow['server_id'] = 0;
- }
- if ($rSettings['streams_grouped'] != 1) {
- } else {
- $rRow['server_id'] = -1;
- }
- if (Authorization::check('adv', 'live_connections')) {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- } else {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- }
- if (SettingsManager::getAll()['hide_failures'] && !$rCreated) {
- $rBtnLength = 'btn-fixed-xl';
- } else {
- $rBtnLength = 'btn-fixed';
- }
- if ($rActualStatus == 1) {
- if (86400 <= $rUptime) {
- $rUptime = sprintf('%02dd %02dh %02dm', $rUptime / 86400, ($rUptime / 3600) % 24, ($rUptime / 60) % 60);
- } else {
- $rUptime = sprintf('%02dh %02dm %02ds', $rUptime / 3600, ($rUptime / 60) % 60, $rUptime % 60);
- }
- $rUptime = "
';
- } else {
- if ($rActualStatus == 3) {
- $rUptime = "
";
- } else {
- if ($rActualStatus == 6) {
- $rSources = json_decode($rRow['stream_source'], true);
- $rLeft = count(array_diff($rSources, json_decode($rRow['cchannel_rsources'], true)));
- $rPercent = intval((count($rSources) - $rLeft) / count($rSources) * 100);
- $rUptime = "
';
- } else {
- $rUptime = $rStatusArray[$rActualStatus];
- }
- }
- }
- if (!in_array($rActualStatus, array(1, 2, 3))) {
- } else {
- if ($rCreated) {
- $rCCInfo = json_decode($rRow['cc_info'], true);
- $rTrackInfo = ($rRow['parent_id'] ? 'Channel is looping from another server, real position cannot be determined.' : 'No information available.');
- if ($rActualStatus == 1 && 0 < count($rCCInfo) && !$rRow['parent_id']) {
- $rSources = json_decode($rRow['stream_source'], true);
- foreach ($rCCInfo as $rTrack) {
- if (!($rTrack['start'] <= $rSeconds && $rSeconds < $rTrack['finish'])) {
- } else {
- $rTrackInfo = pathinfo($rSources[$rTrack['position']])['filename'] . '
Track # ' . ($rTrack['position'] + 1) . ' of ' . count($rSources) . '
';
- if ($rTrack['position'] < count($rSources) - 1) {
- $rTrackInfo .= 'Next track in ' . number_format(($rTrack['finish'] - $rSeconds) / 60, 0) . ' minutes.';
- } else {
- $rTrackInfo .= 'Looping in ' . number_format(($rTrack['finish'] - $rSeconds) / 60, 0) . ' minutes.';
- }
- }
- }
- $rUptime = "
" . $rUptime;
- } else {
- $rUptime = "
" . $rUptime;
- }
- } else {
- if (!(SettingsManager::getAll()['hide_failures'] && stripos($rUptime, 'btn-fixed-xl') === false)) {
- } else {
- $rUptime = str_replace('btn-fixed', 'btn-fixed-xl', $rUptime);
- }
- if ($rSettings['streams_grouped'] == 1) {
- $rFailRow = $rFails[$rRow['id']];
- } else {
- $rFailRow = $rFailsPS[$rRow['id']][$rRow['server_id']];
- }
- if ($rFailRow) {
- } else {
- $rFailRow = array(0, 0);
- }
- if (!SettingsManager::getAll()['hide_failures']) {
- if (!isset($rFailRow) || $rFailRow[0] <= 2) {
- $rUptime = "
" . $rUptime;
- } else {
- if ($rFailRow[0] <= 4 || 21600 < $rFailRow[1]) {
- $rUptime = "
" . $rUptime;
- } else {
- if ($rFailRow[0] <= 144 || 600 < $rFailRow[1]) {
- $rUptime = "
" . $rUptime;
- } else {
- $rUptime = "
" . $rUptime;
- }
- }
- }
- }
- }
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rRow['notes'])) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if ((isset(RequestManager::getAll()['single']) || isset(RequestManager::getAll()['simple'])) && Authorization::check('adv', 'edit_stream')) {
- if (intval($rActualStatus) == 1 || intval($rActualStatus) == 2 || intval($rActualStatus) == 3 || $rRow['on_demand'] == 1 || $rActualStatus == 5) {
- $rButtons .= '
";
- $rStatus = '';
- } else {
- $rButtons .= '
";
- $rStatus = ' disabled';
- }
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t" . '
';
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rButtons .= '
";
- }
- } else {
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_stream')) {
- } else {
- if (intval($rActualStatus) == 1 || intval($rActualStatus) == 2 || intval($rActualStatus) == 3 || $rRow['on_demand'] == 1 || $rActualStatus == 5) {
- $rButtons .= '
";
- $rStatus = '';
- } else {
- $rButtons .= '
";
- $rStatus = ' disabled';
- }
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t\t" . '
';
- }
- if (!Authorization::check('adv', 'fingerprint') || $rCreated) {
- } else {
- if (0 < $rRow['clients']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
';
- }
- }
- if (!Authorization::check('adv', 'edit_stream')) {
- } else {
- if ($rRow['type'] == 3) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
";
- }
- }
- $rButtons .= '
';
- }
- $rStreamInfoText = "
";
- $rStreamInfo = json_decode($rRow['stream_info'], true);
- $rProgressInfo = json_decode($rRow['progress_info'], true);
- if ($rActualStatus == 1) {
- if (!isset($rStreamInfo['codecs']['video'])) {
- $rStreamInfo['codecs']['video'] = array('width' => '?', 'height' => '?', 'codec_name' => 'N/A', 'r_frame_rate' => '--');
- }
- if (!isset($rStreamInfo['codecs']['audio'])) {
- $rStreamInfo['codecs']['audio'] = array('codec_name' => 'N/A');
- }
- if ($rRow['bitrate'] == 0) {
- $rRow['bitrate'] = '?';
- }
- if (isset($rProgressInfo['speed'])) {
- $rSpeed = floor($rProgressInfo['speed'] * 100) / 100 . 'x';
- } else {
- $rSpeed = '1x';
- }
- $rFPS = null;
- if (isset($rProgressInfo['fps'])) {
- $rFPS = intval($rProgressInfo['fps']);
- } else {
- if (isset($rStreamInfo['codecs']['video']['r_frame_rate'])) {
- $rFPS = intval($rStreamInfo['codecs']['video']['r_frame_rate']);
- }
- }
- if ($rFPS) {
- if (1000 < $rFPS) {
- $rFPS = intval($rFPS / 1000);
- }
- $rFPS = $rFPS . ' FPS';
- } else {
- $rFPS = '--';
- }
- $rStreamInfoText = "
| " . number_format($rRow['bitrate'], 0) . " Kbps | | | ";
- if (!$rCreated) {
- $rStreamInfoText .= " | ";
- }
- $rStreamInfoText .= " |
| " . $rStreamInfo['codecs']['video']['width'] . ' x ' . $rStreamInfo['codecs']['video']['height'] . ' | ' . $rStreamInfo['codecs']['video']['codec_name'] . ' | ' . $rStreamInfo['codecs']['audio']['codec_name'] . ' | ';
- if (!$rCreated) {
- $rStreamInfoText .= '' . $rSpeed . ' | ';
- }
- $rStreamInfoText .= '' . $rFPS . ' |
';
- }
- if (Authorization::check('adv', 'player')) {
- if ((intval($rActualStatus) == 1 || $rActualStatus == 4) && !$rRow['direct_proxy']) {
- if (empty($rStreamInfo['codecs']['video']['codec_name']) || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'H264' || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'N/A') {
- $rPlayer = '
';
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- if (file_exists(EPG_PATH . 'stream_' . $rRow['id'])) {
- $rEPG = '
";
- } else {
- if ($rRow['channel_id']) {
- $rEPG = "
";
- } else {
- $rEPG = "
";
- }
- }
- if (0 < strlen($rRow['stream_icon']) && SettingsManager::getAll()['show_images']) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rID = $rRow['id'];
- if ($rSettings['streams_grouped'] || 1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rID .= '-' . $rRow['server_id'];
- }
- if ($rCreated) {
- $rReturn['data'][] = array("
" . $rID . '', $rIcon, $rStreamName, $rServerName, $rClients, $rUptime, $rButtons, $rPlayer, $rStreamInfoText);
- } else {
- $rReturn['data'][] = array("
" . $rID . '', $rIcon, $rStreamName, $rServerName, $rClients, $rUptime, $rButtons, $rPlayer, $rEPG, $rStreamInfoText);
- }
- } else {
- unset($rRow['stream_source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'radios') {
- if (Authorization::check('adv', 'radio') || Authorization::check('adv', 'mass_edit_radio')) {
- $rCategories = CategoryService::getAllByType('radio');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_icon`', '`streams`.`stream_display_name`', '`server_name`', '`clients`', '`streams_servers`.`stream_started`', false, '`streams_servers`.`bitrate`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 4';
- if (isset(RequestManager::getAll()['stream_id'])) {
- $rWhere[] = '`streams`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (!isset(RequestManager::getAll()['refresh'])) {
- } else {
- $rWhere = array('`streams`.`id` IN (' . implode(',', array_map('intval', explode(',', RequestManager::getAll()['refresh']))) . ')');
- $rWhereV = array();
- $rStart = 0;
- $rLimit = 1000;
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`stream_status` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '((`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 1))';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND `streams_servers`.`on_demand` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 2)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams_servers`.`on_demand` = 1';
- } else {
- if (RequestManager::getAll()['filter'] != 6) {
- } else {
- $rWhere[] = '`streams`.`direct_source` = 1';
- }
- }
- }
- }
- }
- }
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rSettings['streams_grouped'] = 0;
- }
- if ($rSettings['streams_grouped'] == 1) {
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- } else {
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- }
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_icon`, `streams`.`movie_properties`, `streams_servers`.`to_analyze`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_icon`, `streams`.`type`, `streams_servers`.`cchannel_rsources`, `streams`.`stream_source`, `streams`.`stream_display_name`, `streams`.`tv_archive_duration`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams_servers`.`parent_id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- }
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped']) {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, true, true);
- } else {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, false, false);
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- } else {
- $rRow['clients'] = (count($rConnectionCount[$rRow['id']][$rRow['server_id']]) ?: 0);
- }
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rStreamName = "
" . $rRow['stream_display_name'] . "
" . $rCategory . '';
- if ($rRow['server_name']) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- if (!($rSettings['streams_grouped'] && 1 < $rServerCount[$rRow['id']])) {
- } else {
- $rServerName .= "
';
- }
- if ($rServers[$rRow['server_id']]['last_status'] == 1) {
- } else {
- $rServerName .= "
Uptime cannot be confirmed.\" type='button' class='tooltip btn btn-danger btn-xs waves-effect waves-light'>
";
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- if ($rSettings['streams_grouped']) {
- } else {
- if (0 < intval($rRow['parent_id'])) {
- $rStreamSource = "
loop: " . strtolower(ServerRepository::getAll()[$rRow['parent_id']]['server_name']) . '';
- } else {
- $rStreamSource = "
" . strtolower(parse_url($rRow['current_source'])['host']) . '';
- }
- $rServerName .= $rStreamSource;
- }
- $rUptime = 0;
- $rActualStatus = 0;
- if (0 >= intval($rRow['stream_started'])) {
- } else {
- $rUptime = time() - intval($rRow['stream_started']);
- }
- if ($rRow['server_id']) {
- if (intval($rRow['direct_source']) == 1) {
- $rActualStatus = 5;
- } else {
- if ($rRow['monitor_pid']) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- if (intval($rRow['stream_status']) == 2) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 1;
- }
- } else {
- if ($rRow['stream_status'] == 0) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 3;
- }
- }
- } else {
- if (intval($rRow['on_demand']) == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 0;
- }
- }
- }
- } else {
- $rActualStatus = -1;
- }
- if ($rRow['server_id']) {
- } else {
- $rRow['server_id'] = 0;
- }
- if ($rSettings['streams_grouped'] != 1) {
- } else {
- $rRow['server_id'] = -1;
- }
- if (Authorization::check('adv', 'live_connections')) {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- } else {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- }
- if ($rActualStatus == 1) {
- if (86400 <= $rUptime) {
- $rUptime = sprintf('%02dd %02dh %02dm', $rUptime / 86400, ($rUptime / 3600) % 24, ($rUptime / 60) % 60);
- } else {
- $rUptime = sprintf('%02dh %02dm %02ds', $rUptime / 3600, ($rUptime / 60) % 60, $rUptime % 60);
- }
- $rUptime = "
';
- } else {
- if ($rActualStatus == 3) {
- $rUptime = "
";
- } else {
- $rUptime = $rStatusArray[$rActualStatus];
- }
- }
- $rUptime = str_replace("btn-fixed'", "btn-fixed-xl'", $rUptime);
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rRow['notes'])) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if ((isset(RequestManager::getAll()['single']) || isset(RequestManager::getAll()['simple'])) && Authorization::check('adv', 'edit_radio')) {
- if (intval($rActualStatus) == 1 || intval($rActualStatus) == 2 || intval($rActualStatus) == 3 || $rRow['on_demand'] == 1 || $rActualStatus == 5) {
- $rButtons .= '
";
- $rStatus = '';
- } else {
- $rButtons .= '
";
- $rStatus = ' disabled';
- }
- $rButtons .= '
';
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rButtons .= '
";
- }
- } else {
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_radio')) {
- } else {
- if (intval($rActualStatus) == 1 || intval($rActualStatus) == 2 || intval($rActualStatus) == 3 || $rRow['on_demand'] == 1 || $rActualStatus == 5) {
- $rButtons .= '
";
- $rStatus = '';
- } else {
- $rButtons .= '
";
- $rStatus = ' disabled';
- }
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t" . '
";
- }
- }
- $rButtons .= '
';
- }
- $rStreamInfoText = "
";
- $rStreamInfo = json_decode($rRow['stream_info'], true);
- $rProgressInfo = json_decode($rRow['progress_info'], true);
- if ($rActualStatus != 1) {
- } else {
- if (isset($rStreamInfo['codecs']['video'])) {
- } else {
- $rStreamInfo['codecs']['video'] = array('width' => '?', 'height' => '?', 'codec_name' => 'N/A', 'r_frame_rate' => '--');
- }
- if (isset($rStreamInfo['codecs']['audio'])) {
- } else {
- $rStreamInfo['codecs']['audio'] = array('codec_name' => 'N/A');
- }
- if ($rRow['bitrate'] != 0) {
- } else {
- $rRow['bitrate'] = '?';
- }
- if (isset($rProgressInfo['speed'])) {
- $rSpeed = floor($rProgressInfo['speed'] * 100) / 100 . 'x';
- } else {
- $rSpeed = '1x';
- }
- $rStreamInfoText = "
" . "\r\n" . ' ' . "\r\n" . ' ' . "\r\n" . " | " . "\r\n" . " | " . "\r\n" . " | " . "\r\n" . '
' . "\r\n" . ' ' . "\r\n" . ' | ' . $rRow['bitrate'] . ' Kbps | ' . "\r\n" . ' ' . $rStreamInfo['codecs']['audio']['codec_name'] . ' | ' . "\r\n" . ' ' . $rSpeed . ' | ' . "\r\n" . '
' . "\r\n" . ' ' . "\r\n" . '
';
- }
- if (0 < strlen($rRow['stream_icon']) && SettingsManager::getAll()['show_images']) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rID = $rRow['id'];
- if ($rSettings['streams_grouped'] || 1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rID .= '-' . $rRow['server_id'];
- }
- $rReturn['data'][] = array("
" . $rID . '', $rIcon, $rStreamName, $rServerName, $rClients, $rUptime, $rButtons, $rStreamInfoText);
- } else {
- unset($rRow['stream_source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'movies') {
- if (Authorization::check('adv', 'movies') || Authorization::check('adv', 'mass_sedits_vod')) {
- $rCategories = CategoryService::getAllByType('movie');
- $rOrder = array('`streams`.`id`', false, '`streams`.`stream_display_name`', '`server_name`', '`clients`', '`streams_servers`.`stream_started`', false, false, false, '`streams_servers`.`bitrate`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 2';
- $rDuplicates = false;
- if (isset(RequestManager::getAll()['stream_id'])) {
- $rWhere[] = '`streams`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (isset(RequestManager::getAll()['source_id'])) {
- $rWhere[] = 'MD5(`streams`.`stream_source`) = ?';
- $rWhereV[] = RequestManager::getAll()['source_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (!isset(RequestManager::getAll()['refresh'])) {
- } else {
- $rWhere = array('`streams`.`id` IN (' . implode(',', array_map('intval', explode(',', RequestManager::getAll()['refresh']))) . ')');
- $rWhereV = array();
- $rStart = 0;
- $rLimit = 1000;
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 1 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` = 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 6) {
- $rWhere[] = "(`streams`.`movie_properties` IS NULL OR `streams`.`movie_properties` = '' OR `streams`.`movie_properties` = '[]' OR `streams`.`movie_properties` = '{}' OR `streams`.`movie_properties` LIKE '%tmdb_id\":\"\"%')";
- } else {
- if (RequestManager::getAll()['filter'] == 7) {
- $rWhere[] = '`streams`.`id` IN (SELECT MIN(`id`) FROM `streams` WHERE `type` = 2 GROUP BY `stream_source` HAVING COUNT(`stream_source`) > 1)';
- $rDuplicates = true;
- } else {
- if (RequestManager::getAll()['filter'] != 8) {
- } else {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['audio'])) {
- } else {
- if (RequestManager::getAll()['audio'] == -1) {
- $rWhere[] = '`streams_servers`.`audio_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`audio_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['audio'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['video'])) {
- } else {
- if (RequestManager::getAll()['video'] == -1) {
- $rWhere[] = '`streams_servers`.`video_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`video_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['video'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['resolution'])) {
- } else {
- $rWhere[] = '`streams_servers`.`resolution` = ?';
- $rWhereV[] = (intval(RequestManager::getAll()['resolution']) ?: null);
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- }
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (isset(RequestManager::getAll()['single'])) {
- $rSettings['streams_grouped'] = 0;
- } else {
- if (!isset(RequestManager::getAll()['grouped'])) {
- } else {
- $rSettings['streams_grouped'] = 1;
- }
- }
- if ($rSettings['streams_grouped'] == 1) {
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- } else {
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- }
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams`.`movie_properties`, `streams`.`year`, `streams_servers`.`to_analyze`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- } else {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams`.`movie_properties`, `streams`.`year`, `streams_servers`.`to_analyze`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- }
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped']) {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, true, true);
- } else {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, false, false);
- }
- }
- if (!$rDuplicates) {
- } else {
- $rDuplicateCount = array();
- $db->query('SELECT MD5(`stream_source`) AS `source`, COUNT(`stream_source`) AS `count` FROM `streams` WHERE `stream_source` IN (SELECT `stream_source` FROM `streams` WHERE `id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ')) GROUP BY `stream_source` HAVING COUNT(`stream_source`) > 1;');
- foreach ($db->get_rows() as $rRow) {
- $rDuplicateCount[$rRow['source']] = $rRow['count'];
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- } else {
- $rRow['clients'] = (count($rConnectionCount[$rRow['id']][$rRow['server_id']]) ?: 0);
- }
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- $rProperties = json_decode($rRow['movie_properties'], true);
- $rRatingText = '';
- if (!$rProperties['rating']) {
- } else {
- $rStarRating = round($rProperties['rating']) / 2;
- $rFullStars = floor($rStarRating);
- $rHalfStar = 0 < $rStarRating - $rFullStars;
- $rEmpty = 5 - ($rFullStars + (($rHalfStar ? 1 : 0)));
- if (0 >= $rFullStars) {
- } else {
- foreach (range(1, $rFullStars) as $i) {
- $rRatingText .= "
";
- }
- }
- if (!$rHalfStar) {
- } else {
- $rRatingText .= "
";
- }
- if (0 >= $rEmpty) {
- } else {
- foreach (range(1, $rEmpty) as $i) {
- $rRatingText .= "
";
- }
- }
- }
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rYear = ($rRow['year'] ? '
' . $rRow['year'] . ' ' : '');
- $rStreamName = "
" . $rRow['stream_display_name'] . "
" . $rYear . $rRatingText . '
' . $rCategory . '';
- if ($rRow['server_name']) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- if (!($rSettings['streams_grouped'] && 1 < $rServerCount[$rRow['id']])) {
- } else {
- $rServerName .= "
';
- }
- if ($rServers[$rRow['server_id']]['last_status'] == 1) {
- } else {
- $rServerName .= "
Uptime cannot be confirmed.\" type='button' class='tooltip btn btn-danger btn-xs waves-effect waves-light'>
";
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- $rUptime = 0;
- if ($rRow['server_id']) {
- $rActualStatus = 0;
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- $rActualStatus = 5;
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (!is_null($rRow['pid']) && 0 < $rRow['pid']) {
- if ($rRow['to_analyze'] == 1) {
- $rActualStatus = 2;
- } else {
- if ($rRow['stream_status'] == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 1;
- }
- }
- } else {
- $rActualStatus = 0;
- }
- }
- } else {
- $rActualStatus = -1;
- }
- if ($rRow['server_id']) {
- } else {
- $rRow['server_id'] = 0;
- }
- if ($rSettings['streams_grouped'] != 1) {
- } else {
- $rRow['server_id'] = -1;
- }
- if (Authorization::check('adv', 'live_connections')) {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- } else {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rRow['notes'])) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if ((isset(RequestManager::getAll()['single']) || isset(RequestManager::getAll()['simple'])) && Authorization::check('adv', 'edit_movie')) {
- if (intval($rActualStatus) == 1) {
- $rButtons .= '
";
- } else {
- if (intval($rActualStatus) == 3 || intval($rActualStatus) == 5) {
- $rButtons .= '
';
- } else {
- if (intval($rActualStatus) == 2) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- }
- }
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rButtons .= '
";
- }
- } else {
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_movie')) {
- } else {
- if (intval($rActualStatus) == 1) {
- $rButtons .= '
";
- } else {
- if (intval($rActualStatus) == 3 || intval($rActualStatus) == 5) {
- $rButtons .= '
';
- } else {
- if (intval($rActualStatus) == 2) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- }
- }
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t\t" . '
";
- }
- }
- $rButtons .= '
';
- }
- if ($rDuplicates) {
- $rDupeCount = ($rDuplicateCount[$rRow['source']] - 1 ?: 0);
- $rStreamInfoText = "
Duplicate of " . $rDupeCount . ' other movie' . (($rDupeCount == 1 ? '' : 's')) . '';
- } else {
- $rStreamInfoText = "
";
- $rStreamInfo = json_decode($rRow['stream_info'], true);
- if ($rActualStatus != 1) {
- } else {
- if (isset($rStreamInfo['codecs']['video'])) {
- } else {
- $rStreamInfo['codecs']['video'] = array('width' => '?', 'height' => '?', 'codec_name' => 'N/A', 'r_frame_rate' => '--');
- }
- if (isset($rStreamInfo['codecs']['audio'])) {
- } else {
- $rStreamInfo['codecs']['audio'] = array('codec_name' => 'N/A');
- }
- if ($rRow['bitrate'] != 0) {
- } else {
- $rRow['bitrate'] = '?';
- }
- $rDuration = (empty($rStreamInfo['duration']) ? '--' : substr($rStreamInfo['duration'], 0, 5));
- $rStreamInfoText = "
" . "\r\n\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t\t" . "| " . number_format($rRow['bitrate'], 0) . ' Kbps | ' . "\r\n\t\t\t\t\t\t\t\t\t" . " | " . "\r\n\t\t\t\t\t\t\t\t\t" . " | " . "\r\n\t\t\t\t\t\t\t\t\t" . " | " . "\r\n\t\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t\t" . "| " . $rStreamInfo['codecs']['video']['width'] . ' x ' . $rStreamInfo['codecs']['video']['height'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t\t" . '' . $rStreamInfo['codecs']['video']['codec_name'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t\t" . '' . $rStreamInfo['codecs']['audio']['codec_name'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t\t" . '' . $rDuration . ' | ' . "\r\n\t\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t" . '
';
- }
- }
- if (Authorization::check('adv', 'player')) {
- if (intval($rActualStatus) == 1 || $rActualStatus == 3) {
- if (empty($rStreamInfo['codecs']['video']['codec_name']) || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'H264' || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'N/A') {
- $rPlayer = '
";
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- if (0 < strlen($rProperties['movie_image']) && SettingsManager::getAll()['show_images']) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- if (isset($rProperties['kinopoisk_url']) && 0 < strlen($rProperties['kinopoisk_url'])) {
- $rTMDB = '
';
- } else {
- $rTMDB = '
';
- }
- $rID = $rRow['id'];
- if ($rSettings['streams_grouped'] || 1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rID .= '-' . $rRow['server_id'];
- }
- $rReturn['data'][] = array("
" . $rID . '', $rImage, $rStreamName, $rServerName, $rClients, $rVODStatusArray[$rActualStatus], $rTMDB, $rButtons, $rPlayer, $rStreamInfoText);
- } else {
- unset($rReturn['source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'episode_list') {
- if (Authorization::check('adv', 'import_episodes') || Authorization::check('adv', 'mass_delete')) {
- $rOrder = array('`streams`.`id`', false, '`streams`.`stream_display_name`', '`streams_servers`.`server_id`', '`streams_servers`.`stream_status`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 5';
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (0 >= strlen(RequestManager::getAll()['series'] ?? '')) {
- } else {
- $rWhere[] = '`streams_episodes`.`series_id` = ?';
- $rWhereV[] = RequestManager::getAll()['series'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 5) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams_series`.`title` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 1 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`stream_status` = 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } else {
- if (RequestManager::getAll()['filter'] != 7) {
- } else {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- }
- }
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if (0 < $db->num_rows()) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams_servers`.`to_analyze`, `streams`.`movie_properties`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams_series`.`title`, `streams_series`.`seasons`, `streams_series`.`id` AS `sid`, `streams_episodes`.`season_num` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- $rActualStatus = 0;
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- $rActualStatus = 5;
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (!is_null($rRow['pid']) && 0 < $rRow['pid']) {
- if ($rRow['to_analyze'] == 1) {
- $rActualStatus = 2;
- } else {
- if ($rRow['stream_status'] == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 1;
- }
- }
- } else {
- $rActualStatus = 0;
- }
- }
- $rSeriesName = $rRow['title'] . ' - Season ' . $rRow['season_num'];
- $rStreamName = '
' . $rRow['stream_display_name'] . "" . $rSeriesName . '';
- if ($rRow['server_name']) {
- $rServerName = $rRow['server_name'];
- if (1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rServerName .= "
';
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- $rImage = '';
- $rProperties = json_decode($rRow['movie_properties'], true);
- if (!(0 < strlen($rProperties['movie_image']) && SettingsManager::getAll()['show_images'])) {
- } else {
- $rImage = "

";
- }
- $rReturn['data'][] = array($rRow['id'], $rImage, $rStreamName, $rServerName, $rVODStatusArray[$rActualStatus]);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'line_activity') {
- if (Authorization::check('adv', 'connection_logs')) {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrder = array('`username` ' . $rOrderDirection . ', `lines_activity`.`hmac_identifier`', '`streams`.`stream_display_name`', '`server_name`', '`lines_activity`.`user_agent`', '`lines_activity`.`isp`', '`lines_activity`.`user_ip`', '`lines_activity`.`date_start`', '`lines_activity`.`activity_id`', '`lines_activity`.`date_end` - `lines_activity`.`date_start`', '`lines_activity`.`container`', '`lines`.`is_restreamer`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 7) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines_activity`.`hmac_identifier` LIKE ? OR `lines_activity`.`user_agent` LIKE ? OR `lines_activity`.`user_ip` LIKE ? OR `lines_activity`.`container` LIKE ? OR FROM_UNIXTIME(`lines_activity`.`date_start`) LIKE ? OR FROM_UNIXTIME(`lines_activity`.`date_end`) LIKE ? OR `lines_activity`.`geoip_country_code` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'] ?? '')) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range'] ?? '') - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`lines_activity`.`date_start` >= ? AND `lines_activity`.`date_end` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['stream'] ?? '')) {
- } else {
- $rWhere[] = '`lines_activity`.`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream'];
- }
- if (0 >= strlen(RequestManager::getAll()['user'] ?? '')) {
- } else {
- $rWhere[] = '`lines_activity`.`user_id` = ?';
- $rWhereV[] = RequestManager::getAll()['user'];
- }
- if (0 >= intval(RequestManager::getAll()['server'] ?? 0)) {
- } else {
- $rWhere[] = '(`lines_activity`.`server_id` = ? OR `lines_activity`.`proxy_id` = ?)';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines_activity` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines`.`username`, `lines`.`is_e2`, `lines`.`is_mag`, `lines_activity`.`activity_id`, `lines_activity`.`hmac_identifier`, `lines_activity`.`hmac_id`, `lines_activity`.`proxy_id`, `lines_activity`.`container`, `lines_activity`.`isp`, `lines_activity`.`user_id`, `lines_activity`.`stream_id`, `streams`.`series_no`, `lines_activity`.`server_id`, `lines_activity`.`user_agent`, `lines_activity`.`user_ip`, `lines_activity`.`container`, `lines_activity`.`date_start`, `lines_activity`.`date_end`, `lines_activity`.`geoip_country_code`, `streams`.`stream_display_name`, `streams`.`type`, (SELECT `server_name` FROM `servers` WHERE `id` = `lines_activity`.`server_id`) AS `server_name`, `lines`.`is_restreamer` FROM `lines_activity` LEFT JOIN `lines` ON `lines_activity`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_activity`.`stream_id` = `streams`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rDeviceInfo = $rMagIDs = $rEnigmaIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['is_mag']) {
- } else {
- $rMagIDs[] = intval($rRow['user_id']);
- }
- if (!$rRow['is_e2']) {
- } else {
- $rEnigmaIDs[] = intval($rRow['user_id']);
- }
- if (!($rRow['is_mag'] || $rRow['is_e2'])) {
- } else {
- $rDeviceInfo[intval($rRow['user_id'])] = array('device_id' => null, 'device_name' => null);
- }
- }
- if (0 >= count($rMagIDs)) {
- } else {
- $db->query('SELECT `user_id`, `mag_id`, `mac` FROM `mag_devices` WHERE `user_id` IN (' . implode(',', $rMagIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rDeviceInfo[intval($rRow['user_id'])]['device_id'] = $rRow['mag_id'];
- $rDeviceInfo[intval($rRow['user_id'])]['device_name'] = $rRow['mac'];
- }
- }
- if (0 >= count($rEnigmaIDs)) {
- } else {
- $db->query('SELECT `user_id`, `device_id`, `mac` FROM `enigma2_devices` WHERE `user_id` IN (' . implode(',', $rEnigmaIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rDeviceInfo[intval($rRow['user_id'])]['device_id'] = $rRow['device_id'];
- $rDeviceInfo[intval($rRow['user_id'])]['device_name'] = $rRow['mac'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!isset($rDeviceInfo[$rRow['user_id']])) {
- } else {
- $rRow = array_merge($rRow, $rDeviceInfo[$rRow['user_id']]);
- }
- if (!$rIsAPI) {
- if ($rRow['hmac_id']) {
- if (Authorization::check('adv', 'add_hmac')) {
- $rUsername = "
HMAC - " . $rRow['hmac_identifier'] . '';
- } else {
- $rUsername = 'HMAC - ' . $rRow['hmac_identifier'];
- }
- } else {
- if ($rRow['is_mag']) {
- if (Authorization::check('adv', 'edit_mag')) {
- $rUsername = "
" . $rRow['username'] . "
MAC: " . $rRow['device_name'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- } else {
- if ($rRow['is_e2']) {
- if (Authorization::check('adv', 'edit_e2')) {
- $rUsername = "
" . $rRow['username'] . '
' . $rRow['device_name'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- } else {
- if (Authorization::check('adv', 'users')) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- }
- }
- }
- $rPermission = array(1 => 'streams', 2 => 'movies', 3 => 'streams', 4 => 'radio', 5 => 'series');
- $rURLs = array(1 => 'stream_view', 2 => 'stream_view', 3 => 'stream_view', 4 => 'stream_view');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- if ($rRow['type'] == 5) {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- }
- } else {
- $rChannel = $rRow['stream_display_name'];
- }
- if (Authorization::check('adv', 'servers')) {
- $rServer = "
" . $rRow['server_name'] . '';
- } else {
- $rServer = $rRow['server_name'];
- }
- if (!(0 < $rRow['proxy_id'] && isset($rProxyServers[$rRow['proxy_id']]))) {
- } else {
- $rServer .= '
(via ' . $rProxyServers[$rRow['proxy_id']]['server_name'] . ')';
- }
- if (0 < strlen($rRow['geoip_country_code'])) {
- $rGeoCountry = "

";
- } else {
- $rGeoCountry = '';
- }
- if ($rRow['user_ip']) {
- $rExplode = explode(':', $rRow['user_ip']);
- $rIP = $rGeoCountry . "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['user_ip'])) . '';
- } else {
- $rIP = '';
- }
- if ($rRow['date_start']) {
- $rStart = date($rSettings['datetime_format'], $rRow['date_start']);
- } else {
- $rStart = '';
- }
- if ($rRow['date_end']) {
- $rStop = date($rSettings['datetime_format'], $rRow['date_end']);
- } else {
- $rStop = '';
- }
- $rPlayer = trim(explode('(', $rRow['user_agent'])[0]);
- $rDuration = $rRow['date_end'] - $rRow['date_start'];
- $rColour = 'success';
- if (86400 <= $rDuration) {
- $rDuration = sprintf('%02dd %02dh', $rDuration / 86400, ($rDuration / 3600) % 24);
- $rColour = 'danger';
- } else {
- if (3600 <= $rDuration) {
- if (14400 < $rDuration) {
- $rColour = 'warning';
- } else {
- if (43200 >= $rDuration) {
- } else {
- $rColour = 'danger';
- }
- }
- $rDuration = sprintf('%02dh %02dm', $rDuration / 3600, ($rDuration / 60) % 60);
- } else {
- $rDuration = sprintf('%02dm %02ds', ($rDuration / 60) % 60, $rDuration % 60);
- }
- }
- if (!$rRow['is_restreamer']) {
- } else {
- $rColour = 'success';
- }
- $rDuration = "
';
- if ($rRow['is_restreamer'] == 1) {
- $rRestreamer = '
';
- } else {
- $rRestreamer = '
';
- }
- $rReturn['data'][] = array($rUsername, $rChannel, $rServer, $rPlayer, $rRow['isp'], $rIP, $rStart, $rStop, $rDuration, strtoupper($rRow['container']), $rRestreamer);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'live_connections') {
- if (Authorization::check('adv', 'live_connections')) {
- $rRows = array();
- if (SettingsManager::getAll()['redis_handler']) {
- $rRedis = RedisManager::instance();
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? false : true);
- $rFilterBefore = true;
- if (isset(RequestManager::getAll()['refresh'])) {
- $rStart = 0;
- $rLimit = 1000;
- $rKeys = explode(',', RequestManager::getAll()['refresh']);
- } else {
- $rServerID = (0 < intval(RequestManager::getAll()['server_id'] ?? 0) ? intval(RequestManager::getAll()['server_id'] ?? 0) : null);
- $rStreamID = (0 < intval(RequestManager::getAll()['stream_id'] ?? 0) ? intval(RequestManager::getAll()['stream_id'] ?? 0) : null);
- $rUserID = (0 < intval(RequestManager::getAll()['user_id'] ?? 0) ? intval(RequestManager::getAll()['user_id'] ?? 0) : null);
- if ($rUserID) {
- if ($rServerID || $rStreamID) {
- $rKeys = $rRedis->zRevRangeByScore('LINE#' . $rUserID, '+inf', '-inf');
- $rFilterBefore = false;
- } else {
- if ($rOrderDirection) {
- $rKeys = $rRedis->zRangeByScore('LINE#' . $rUserID, '-inf', '+inf', array('limit' => array($rStart, $rLimit)));
- } else {
- $rKeys = $rRedis->zRevRangeByScore('LINE#' . $rUserID, '+inf', '-inf', array('limit' => array($rStart, $rLimit)));
- }
- $rKeyCount = $rRedis->zCard('LINE#' . $rUserID);
- }
- } else {
- if ($rStreamID) {
- if ($rUserID || $rServerID) {
- $rKeys = $rRedis->zRevRangeByScore('STREAM#' . $rStreamID, '+inf', '-inf');
- $rFilterBefore = false;
- } else {
- if ($rOrderDirection) {
- $rKeys = $rRedis->zRangeByScore('STREAM#' . $rStreamID, '-inf', '+inf', array('limit' => array($rStart, $rLimit)));
- } else {
- $rKeys = $rRedis->zRevRangeByScore('STREAM#' . $rStreamID, '+inf', '-inf', array('limit' => array($rStart, $rLimit)));
- }
- $rKeyCount = $rRedis->zCard('STREAM#' . $rStreamID);
- }
- } else {
- if ($rServerID) {
- if ($rUserID || $rStreamID) {
- $rKeys = $rRedis->zRevRangeByScore('SERVER#' . $rServerID, '+inf', '-inf');
- $rFilterBefore = false;
- } else {
- if ($rOrderDirection) {
- $rKeys = $rRedis->zRangeByScore('SERVER#' . $rServerID, '-inf', '+inf', array('limit' => array($rStart, $rLimit)));
- } else {
- $rKeys = $rRedis->zRevRangeByScore('SERVER#' . $rServerID, '+inf', '-inf', array('limit' => array($rStart, $rLimit)));
- }
- $rKeyCount = $rRedis->zCard('SERVER#' . $rServerID);
- }
- } else {
- if ($rOrderDirection) {
- $rKeys = $rRedis->zRangeByScore('LIVE', '-inf', '+inf', array('limit' => array($rStart, $rLimit)));
- } else {
- $rKeys = $rRedis->zRevRangeByScore('LIVE', '+inf', '-inf', array('limit' => array($rStart, $rLimit)));
- }
- $rKeyCount = $rRedis->zCard('LIVE');
- }
- }
- }
- }
- if (!$rOrderDirection || $rFilterBefore) {
- } else {
- $rKeys = array_reverse($rKeys);
- }
- if ($rFilterBefore) {
- } else {
- $rKeyCount = count($rKeys);
- }
- foreach ($rRedis->mGet($rKeys) as $rRow) {
- $rRow = igbinary_unserialize($rRow);
- if (is_array($rRow)) {
- if ($rFilterBefore) {
- } else {
- if (!($rServerID && $rServerID != $rRow['server_id'])) {
- if (!($rStreamID && $rStreamID != $rRow['stream_id'])) {
- if (!($rUserID && $rUserID != $rRow['user_id'])) {
- } else {
- $rKeyCount--;
- }
- } else {
- $rKeyCount--;
- }
- } else {
- $rKeyCount--;
- }
- }
- $rRow['activity_id'] = $rRow['uuid'];
- $rRow['identifier'] = ($rRow['user_id'] ?: $rRow['hmac_id'] . '_' . $rRow['hmac_identifier']);
- $rRow['active_time'] = time() - $rRow['date_start'];
- $rRow['server_name'] = (ServerRepository::getAll()[$rRow['server_id']]['server_name'] ?: '');
- $rRows[] = $rRow;
- } else {
- $rKeyCount--;
- }
- }
- if ($rFilterBefore) {
- } else {
- $rRows = array_slice($rRows, $rStart, $rLimit);
- }
- $rUUIDs = $rStreamIDs = $rUserIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['stream_id']) {
- } else {
- $rStreamIDs[] = intval($rRow['stream_id']);
- }
- if (!$rRow['user_id']) {
- } else {
- $rUserIDs[] = intval($rRow['user_id']);
- }
- if (!$rRow['uuid']) {
- } else {
- $rUUIDs[] = $rRow['uuid'];
- }
- }
- $rStreamNames = $rDivergenceMap = $rSeriesMap = $rUserMap = array();
- if (0 >= count($rUserIDs)) {
- } else {
- $db->query('SELECT `lines`.`id`, `lines`.`is_mag`, `lines`.`is_e2`, `lines`.`is_restreamer`, `lines`.`username`, `mag_devices`.`mag_id`, `enigma2_devices`.`device_id` FROM `lines` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines`.`id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` WHERE `lines`.`id` IN (' . implode(',', $rUserIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rUserID = $rRow['id'];
- unset($rRow['id']);
- $rUserMap[$rUserID] = $rRow;
- }
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, `series_id` FROM `streams_episodes` WHERE `stream_id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rSeriesMap[$rRow['stream_id']] = $rRow['series_id'];
- }
- $db->query('SELECT `id`, `type`, `stream_display_name` FROM `streams` WHERE `id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rStreamNames[$rRow['id']] = array($rRow['stream_display_name'], $rRow['type']);
- }
- }
- if (0 >= count($rUUIDs)) {
- } else {
- $db->query("SELECT `uuid`, `divergence` FROM `lines_divergence` WHERE `uuid` IN ('" . implode("','", $rUUIDs) . "');");
- foreach ($db->get_rows() as $rRow) {
- $rDivergenceMap[$rRow['uuid']] = $rRow['divergence'];
- }
- }
- $i = 0;
- while ($i < count($rRows)) {
- $rRows[$i]['divergence'] = ($rDivergenceMap[$rRows[$i]['uuid']] ?: 0);
- $rRows[$i]['series_no'] = ($rSeriesMap[$rRows[$i]['stream_id']] ?: null);
- $rRows[$i]['stream_display_name'] = ($rStreamNames[$rRows[$i]['stream_id']][0] ?: '');
- $rRows[$i]['type'] = ($rStreamNames[$rRows[$i]['stream_id']][1] ?: 1);
- $rRows[$i] = array_merge($rRows[$i], ($rUserMap[$rRows[$i]['user_id']] ?: array()));
- $i++;
- }
- $rReturn['recordsTotal'] = $rKeyCount;
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrder = array('`lines_live`.`activity_id`', '`lines_live`.`divergence`', '`username` ' . $rOrderDirection . ', `lines_live`.`hmac_identifier`', '`streams`.`stream_display_name`', '`server_name`', '`lines_live`.`user_agent`', '`lines_live`.`isp`', '`lines_live`.`user_ip`', 'UNIX_TIMESTAMP() - `lines_live`.`date_start`', '`lines_live`.`container`', '`lines`.`is_restreamer`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`hls_end` = 0';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 10) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines_live`.`hmac_identifier` LIKE ? OR `lines_live`.`user_agent` LIKE ? OR `lines_live`.`user_ip` LIKE ? OR `lines_live`.`container` LIKE ? OR FROM_UNIXTIME(`lines_live`.`date_start`) LIKE ? OR `lines_live`.`geoip_country_code` LIKE ? OR `lines`.`username` LIKE ? OR `mag_devices`.`mac` LIKE ? OR `enigma2_devices`.`mac` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (0 >= intval(RequestManager::getAll()['server_id'] ?? 0)) {
- } else {
- $rWhere[] = '(`lines_live`.`server_id` = ? OR `lines_live`.`proxy_id` = ?)';
- $rWhereV[] = RequestManager::getAll()['server_id'];
- $rWhereV[] = RequestManager::getAll()['server_id'];
- }
- if (0 >= intval(RequestManager::getAll()['stream_id'] ?? 0)) {
- } else {
- $rWhere[] = '`lines_live`.`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- }
- if (0 >= intval(RequestManager::getAll()['user_id'] ?? 0)) {
- } else {
- $rWhere[] = '`lines_live`.`user_id` = ?';
- $rWhereV[] = RequestManager::getAll()['user_id'];
- }
- if (isset(RequestManager::getAll()['refresh'])) {
- $rWhere = array('`lines_live`.`activity_id` IN (' . implode(',', array_map('intval', explode(',', RequestManager::getAll()['refresh']))) . ') AND `hls_end` = 0');
- $rWhereV = array();
- $rStart = 0;
- $rLimit = 1000;
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`lines`.`is_mag` = 0 AND `lines`.`is_e2` = 0 AND `lines`.`is_restreamer` = 0 AND `lines`.`is_stalker` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`lines`.`is_mag` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '`lines`.`is_e2` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '`lines`.`is_trial` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`lines`.`is_restreamer` = 1';
- } else {
- if (RequestManager::getAll()['filter'] != 6) {
- } else {
- $rWhere[] = '`lines`.`is_stalker` = 1';
- }
- }
- }
- }
- }
- }
- }
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines_live` LEFT JOIN `lines` ON `lines_live`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_live`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_live`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_live`.`user_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `mag_devices`.`mag_id`, `enigma2_devices`.`device_id`, `lines`.`is_e2`, `lines`.`is_mag`, `lines_live`.`activity_id`, `lines_live`.`hmac_id`, `lines_live`.`hmac_identifier`, `lines_live`.`proxy_id`, `lines_live`.`divergence`, `lines_live`.`user_id`, `lines_live`.`stream_id`, `streams`.`series_no`, `lines`.`is_restreamer`, `lines_live`.`isp`, `lines_live`.`server_id`, `lines_live`.`user_agent`, `lines_live`.`user_ip`, `lines_live`.`container`, `lines_live`.`pid`, `lines_live`.`uuid`, `lines_live`.`date_start`, `lines_live`.`geoip_country_code`, IF(`lines`.`is_mag`, `mag_devices`.`mac`, IF(`lines`.`is_e2`, `enigma2_devices`.`mac`, `lines`.`username`)) AS `username`, `streams`.`stream_display_name`, `streams`.`type`, (SELECT `server_name` FROM `servers` WHERE `id` = `lines_live`.`server_id`) AS `server_name` FROM `lines_live` LEFT JOIN `lines` ON `lines_live`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_live`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_live`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_live`.`user_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- }
- }
- }
- if (0 >= count($rRows)) {
- } else {
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['divergence'] <= 50) {
- $rDivergence = '
';
- } else {
- if ($rRow['divergence'] <= 80) {
- $rDivergence = '
';
- } else {
- $rDivergence = '
';
- }
- }
- if ($rRow['hmac_id']) {
- if (Authorization::check('adv', 'add_hmac')) {
- $rUsername = "
HMAC - " . $rRow['hmac_identifier'] . '';
- } else {
- $rUsername = 'HMAC - ' . $rRow['hmac_identifier'];
- }
- } else {
- if ($rRow['is_mag']) {
- if (Authorization::check('adv', 'edit_mag')) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- } else {
- if ($rRow['is_e2']) {
- if (Authorization::check('adv', 'edit_e2')) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- } else {
- if (Authorization::check('adv', 'users')) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- }
- }
- }
- $rPermission = array(1 => 'streams', 2 => 'movies', 3 => 'streams', 4 => 'radio', 5 => 'series');
- $rURLs = array(1 => 'stream_view', 2 => 'stream_view', 3 => 'stream_view', 4 => 'stream_view');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- if ($rRow['type'] == 5) {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- }
- } else {
- $rChannel = $rRow['stream_display_name'];
- }
- if (Authorization::check('adv', 'servers')) {
- $rServer = "
" . $rRow['server_name'] . '';
- } else {
- $rServer = $rRow['server_name'];
- }
- if (!(0 < $rRow['proxy_id'] && isset($rProxyServers[$rRow['proxy_id']]))) {
- } else {
- $rServer .= '
(via ' . $rProxyServers[$rRow['proxy_id']]['server_name'] . ')';
- }
- if (0 < strlen($rRow['geoip_country_code'])) {
- $rGeoCountry = "

";
- } else {
- $rGeoCountry = '';
- }
- if ($rRow['user_ip']) {
- $rExplode = explode(':', $rRow['user_ip']);
- $rIP = $rGeoCountry . "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['user_ip'])) . '';
- } else {
- $rIP = '';
- }
- $rPlayer = trim(explode('(', $rRow['user_agent'])[0]);
- $rDuration = intval(time()) - intval($rRow['date_start']);
- $rColour = 'success';
- if ($rRow['hls_end']) {
- $rDuration = "
";
- } else {
- if (86400 <= $rDuration) {
- $rDuration = sprintf('%02dd %02dh', $rDuration / 86400, ($rDuration / 3600) % 24);
- $rColour = 'danger';
- } else {
- if (3600 <= $rDuration) {
- if (14400 < $rDuration) {
- $rColour = 'warning';
- } else {
- if (43200 >= $rDuration) {
- } else {
- $rColour = 'danger';
- }
- }
- $rDuration = sprintf('%02dh %02dm', $rDuration / 3600, ($rDuration / 60) % 60);
- } else {
- $rDuration = sprintf('%02dm %02ds', ($rDuration / 60) % 60, $rDuration % 60);
- }
- }
- if (!$rRow['is_restreamer']) {
- } else {
- $rColour = 'success';
- }
- $rDuration = "
';
- }
- if ($rRow['is_restreamer'] == 1) {
- $rRestreamer = '
';
- } else {
- $rRestreamer = '
';
- }
- $rButtons = '
';
- if (isset(RequestManager::getAll()['fingerprint'])) {
- $rButtons .= "";
- } else {
- $rButtons .= "";
- if (!(Authorization::check('adv', 'fingerprint') && 0 < intval($rRow['user_id']) && $rRow['type'] == 1)) {
- } else {
- $rButtons .= '";
- }
- }
- $rButtons .= '
';
- $rReturn['data'][] = array($rRow['activity_id'], $rDivergence, $rUsername, $rChannel, $rServer, $rPlayer, $rRow['isp'], $rIP, $rDuration, strtoupper($rRow['container']), $rRestreamer, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- } else {
- exit();
- }
-}
-if ($rType == 'stream_list') {
- if (Authorization::check('adv', 'import_streams') || Authorization::check('adv', 'mass_delete')) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_icon`', '`streams`.`stream_display_name`', '`streams`.`category_id`', '`streams_servers`.`server_id`', '`streams_servers`.`stream_status`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (isset(RequestManager::getAll()['include_channels'])) {
- $rWhere[] = '`streams`.`type` IN (1,3)';
- } else {
- if (isset(RequestManager::getAll()['only_channels'])) {
- $rWhere[] = '`streams`.`type` = 3';
- } else {
- $rWhere[] = '`streams`.`type` = 1';
- }
- }
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (!isset(RequestManager::getAll()['only_channels'])) {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`stream_status` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '((`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 1))';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND `streams_servers`.`on_demand` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 2)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams_servers`.`on_demand` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 6) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 7) {
- $rWhere[] = '`streams`.`tv_archive_server_id` > 0 AND `streams`.`tv_archive_duration` > 0';
- } else {
- if (RequestManager::getAll()['filter'] == 8) {
- if ($rSettings['streams_grouped'] == 1) {
- $rWhere[] = "(SELECT COUNT(*) AS `count` FROM `streams_logs` WHERE `streams_logs`.`action` = 'STREAM_FAILED' AND `streams_logs`.`date` >= UNIX_TIMESTAMP()-86400 AND `streams_logs`.`stream_id` = `streams`.`id`) > 144";
- } else {
- $rWhere[] = "(SELECT COUNT(*) AS `count` FROM `streams_logs` WHERE `streams_logs`.`action` = 'STREAM_FAILED' AND `streams_logs`.`date` >= UNIX_TIMESTAMP()-86400 AND `streams_logs`.`stream_id` = `streams`.`id` AND `streams_logs`.`server_id` = `streams_servers`.`server_id`) > 144";
- }
- } else {
- if (RequestManager::getAll()['filter'] == 9) {
- $rWhere[] = 'LENGTH(`streams`.`channel_id`) > 0';
- } else {
- if (RequestManager::getAll()['filter'] == 10) {
- $rWhere[] = '(`streams`.`channel_id` IS NULL OR LENGTH(`streams`.`channel_id`) = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 11) {
- $rWhere[] = '`streams`.`adaptive_link` IS NOT NULL';
- } else {
- if (RequestManager::getAll()['filter'] == 12) {
- $rWhere[] = '`streams`.`title_sync` IS NOT NULL';
- } else {
- if (RequestManager::getAll()['filter'] != 13) {
- } else {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = "(`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND (REPLACE(`streams_servers`.`cchannel_rsources`, '\\\\/', '/') = REPLACE(`streams`.`stream_source`, '\\\\/', '/'))";
- } else {
- if (RequestManager::getAll()['filter'] != 3) {
- } else {
- $rWhere[] = "(REPLACE(`streams_servers`.`cchannel_rsources`, '\\\\/', '/') <> REPLACE(`streams`.`stream_source`, '\\\\/', '/'))";
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM (SELECT `id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id`) t1;';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams_servers`.`stream_id`, `streams`.`type`, `streams`.`stream_icon`, `streams`.`adaptive_link`, `streams`.`title_sync`, `streams_servers`.`cchannel_rsources`, `streams`.`stream_source`, `streams`.`stream_display_name`, `streams`.`tv_archive_duration`, `streams`.`tv_archive_server_id`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`cc_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams`.`epg_id`, `streams`.`channel_id` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ', -`stream_started` DESC LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rStreamName = $rRow['stream_display_name'];
- if ($rRow['server_name']) {
- $rServerName = $rRow['server_name'];
- if (1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rServerName .= "
';
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- $rUptime = 0;
- $rActualStatus = 0;
- if (0 >= intval($rRow['stream_started'])) {
- } else {
- $rUptime = time() - intval($rRow['stream_started']);
- }
- if ($rRow['server_id']) {
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- $rActualStatus = 7;
- } else {
- $rActualStatus = 5;
- }
- } else {
- if ($rRow['monitor_pid']) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- if (intval($rRow['stream_status']) == 2) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 1;
- }
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (intval($rRow['on_demand']) == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 0;
- }
- }
- }
- } else {
- $rActualStatus = -1;
- }
- if (0 < strlen($rRow['stream_icon'])) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rIcon, $rStreamName, $rCategory, $rServerName, $rStatusArray[$rActualStatus]);
- } else {
- unset($rRow['stream_source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'movie_list') {
- if (Authorization::check('adv', 'import_movies') || Authorization::check('adv', 'mass_delete')) {
- $rCategories = CategoryService::getAllByType('movie');
- $rOrder = array('`streams`.`id`', false, '`streams`.`stream_display_name`', '`streams`.`category_id`', '`streams_servers`.`server_id`', '`streams_servers`.`stream_status`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 2';
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 1 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` = 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 6) {
- $rWhere[] = "(`streams`.`movie_properties` IS NULL OR `streams`.`movie_properties` = '' OR `streams`.`movie_properties` = '[]' OR `streams`.`movie_properties` = '{}' OR `streams`.`movie_properties` LIKE '%tmdb_id\":\"\"%')";
- } else {
- if (RequestManager::getAll()['filter'] == 7) {
- $rWhere[] = '`streams`.`id` IN (SELECT MIN(`id`) FROM `streams` WHERE `type` = 2 GROUP BY `stream_source` HAVING COUNT(`stream_source`) > 1)';
- $rDuplicates = true;
- } else {
- if (RequestManager::getAll()['filter'] != 8) {
- } else {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams`.`movie_properties`, `streams`.`year`, `streams_servers`.`to_analyze`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- $rActualStatus = 0;
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- $rActualStatus = 5;
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (!is_null($rRow['pid']) && 0 < $rRow['pid']) {
- if ($rRow['to_analyze'] == 1) {
- $rActualStatus = 2;
- } else {
- if ($rRow['stream_status'] == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 1;
- }
- }
- } else {
- $rActualStatus = 0;
- }
- }
- if ($rRow['server_name']) {
- $rServerName = $rRow['server_name'];
- if (1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rServerName .= "
';
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rProperties = json_decode($rRow['movie_properties'], true);
- $rRatingText = '';
- if (!$rProperties['rating']) {
- } else {
- $rStarRating = round($rProperties['rating']) / 2;
- $rFullStars = floor($rStarRating);
- $rHalfStar = 0 < $rStarRating - $rFullStars;
- $rEmpty = 5 - ($rFullStars + (($rHalfStar ? 1 : 0)));
- if (0 >= $rFullStars) {
- } else {
- foreach (range(1, $rFullStars) as $i) {
- $rRatingText .= "
";
- }
- }
- if (!$rHalfStar) {
- } else {
- $rRatingText .= "
";
- }
- if (0 >= $rEmpty) {
- } else {
- foreach (range(1, $rEmpty) as $i) {
- $rRatingText .= "
";
- }
- }
- }
- $rYear = ($rRow['year'] ? '
' . $rRow['year'] . ' ' : '');
- $rStreamName = $rRow['stream_display_name'] . "
" . $rYear . $rRatingText . '';
- if (0 < strlen($rProperties['movie_image']) && SettingsManager::getAll()['show_images']) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- if (isset($rProperties['kinopoisk_url']) && 0 < strlen($rProperties['kinopoisk_url'])) {
- $rTMDB = '
';
- } else {
- $rTMDB = '
';
- }
- $rReturn['data'][] = array($rRow['id'], $rImage, $rStreamName, $rCategory, $rServerName, $rVODStatusArray[$rActualStatus], $rTMDB);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'radio_list') {
- if (Authorization::check('adv', 'mass_delete')) {
- $rCategories = CategoryService::getAllByType('radio');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_icon`', '`streams`.`stream_display_name`', '`streams`.`category_id`', '`streams_servers`.`server_id`', '`streams_servers`.`stream_status`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 4';
- if (0 < intval(RequestManager::getAll()['category'] ?? 0)) {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- } else {
- if (intval(RequestManager::getAll()['category'] ?? 0) != -1) {
- } else {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- }
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams_servers`.`monitor_pid` > 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`stream_status` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '((`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 1))';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NULL OR `streams_servers`.`monitor_pid` <= 0) AND `streams_servers`.`on_demand` = 0)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`monitor_pid` IS NOT NULL AND `streams_servers`.`monitor_pid` > 0) AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` = 2)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams_servers`.`on_demand` = 1';
- } else {
- if (RequestManager::getAll()['filter'] != 6) {
- } else {
- $rWhere[] = '`streams`.`direct_source` = 1';
- }
- }
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_icon`, `streams`.`movie_properties`, `streams_servers`.`to_analyze`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rUptime = 0;
- $rActualStatus = 0;
- if (0 >= intval($rRow['stream_started'])) {
- } else {
- $rUptime = time() - intval($rRow['stream_started']);
- }
- if ($rRow['server_id']) {
- if (intval($rRow['direct_source']) == 1) {
- $rActualStatus = 5;
- } else {
- if ($rRow['monitor_pid']) {
- if ($rRow['pid'] && 0 < $rRow['pid']) {
- if (intval($rRow['stream_status']) == 2) {
- $rActualStatus = 2;
- } else {
- $rActualStatus = 1;
- }
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (intval($rRow['on_demand']) == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 0;
- }
- }
- }
- } else {
- $rActualStatus = -1;
- }
- if ($rRow['server_name']) {
- $rServerName = $rRow['server_name'];
- if (1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rServerName .= "
';
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- if (0 < strlen($rRow['stream_icon']) && SettingsManager::getAll()['show_images']) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rIcon, $rRow['stream_display_name'], $rCategory, $rServerName, $rStatusArray[$rActualStatus]);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'series_list') {
- if (Authorization::check('adv', 'mass_delete')) {
- $rCategories = CategoryService::getAllByType('series');
- $rOrder = array('`streams_series`.`id`', '`streams_series`.`cover`', '`streams_series`.`title`', '`streams_series`.`category_id`', '`latest_season`', '`episode_count`', false, '`streams_series`.`release_date`', '`streams_series`.`last_modified`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['category'] ?? '')) {
- } else {
- if (RequestManager::getAll()['category'] == -1) {
- $rWhere[] = '(`streams_series`.`tmdb_id` = 0 OR `streams_series`.`tmdb_id` IS NULL)';
- } else {
- if (RequestManager::getAll()['category'] == -2) {
- $rWhere[] = "(`streams`.`category_id` = '[]' OR `streams`.`category_id` IS NULL)";
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams_series`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams_series`.`id` LIKE ? OR `streams_series`.`title` LIKE ? OR `streams_series`.`release_date` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_series` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams_series`.`id`, `streams_series`.`year`, `streams_series`.`rating`, `streams_series`.`cover`, `streams_series`.`title`, `streams_series`.`category_id`, `streams_series`.`tmdb_id`, `streams_series`.`release_date`, `streams_series`.`last_modified`, (SELECT MAX(`season_num`) FROM `streams_episodes` WHERE `series_id` = `streams_series`.`id`) AS `latest_season`, (SELECT COUNT(*) FROM `streams_episodes` WHERE `series_id` = `streams_series`.`id`) AS `episode_count` FROM `streams_series` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (0 < $rRow['latest_season']) {
- $rRow['latest_season'] = "
';
- } else {
- $rRow['latest_season'] = "
";
- }
- if (0 < $rRow['episode_count']) {
- $rRow['episode_count'] = "
';
- } else {
- $rRow['episode_count'] = "
";
- }
- if ($rRow['last_modified'] == 0) {
- $rRow['last_modified'] = 'Never';
- } else {
- $rRow['last_modified'] = date($rSettings['datetime_format'], $rRow['last_modified']);
- }
- if (!$rRow['release_date']) {
- } else {
- $rRow['release_date'] = date($rSettings['date_format'], strtotime($rRow['release_date']));
- }
- if (0 < $rRow['tmdb_id']) {
- $rTMDB = '
';
- } else {
- $rTMDB = '
';
- }
- if (0 < strlen($rRow['cover'])) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- $rRatingText = '';
- if (!$rRow['rating']) {
- } else {
- $rStarRating = round($rRow['rating']) / 2;
- $rFullStars = floor($rStarRating);
- $rHalfStar = 0 < $rStarRating - $rFullStars;
- $rEmpty = 5 - ($rFullStars + (($rHalfStar ? 1 : 0)));
- if (0 >= $rFullStars) {
- } else {
- foreach (range(1, $rFullStars) as $i) {
- $rRatingText .= "
";
- }
- }
- if (!$rHalfStar) {
- } else {
- $rRatingText .= "
";
- }
- if (0 >= $rEmpty) {
- } else {
- foreach (range(1, $rEmpty) as $i) {
- $rRatingText .= "
";
- }
- }
- }
- $rYear = ($rRow['year'] ? '
' . $rRow['year'] . ' ' : '');
- $rTitle = '
' . $rRow['title'] . "" . $rYear . $rRatingText . '';
- $rReturn['data'][] = array($rRow['id'], $rImage, $rTitle, $rCategory, $rRow['latest_season'], $rRow['episode_count'], $rTMDB, $rRow['release_date'], $rRow['last_modified']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'credits_log') {
- if (Authorization::check('adv', 'credits_log')) {
- $rOrder = array('`users_credits_logs`.`id`', '`owner_username`', '`target_username`', '`users_credits_logs`.`amount`', '`users_credits_logs`.`reason`', '`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 5) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`target`.`username` LIKE ? OR `owner`.`username` LIKE ? OR FROM_UNIXTIME(`date`) LIKE ? OR `users_credits_logs`.`amount` LIKE ? OR `users_credits_logs`.`reason` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'] ?? '')) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range'] ?? '') - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`users_credits_logs`.`date` >= ? AND `users_credits_logs`.`date` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'] ?? '')) {
- } else {
- $rWhere[] = '(`users_credits_logs`.`target_id` = ? OR `users_credits_logs`.`admin_id` = ?)';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `users_credits_logs` LEFT JOIN `users` AS `target` ON `target`.`id` = `users_credits_logs`.`target_id` LEFT JOIN `users` AS `owner` ON `owner`.`id` = `users_credits_logs`.`admin_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `users_credits_logs`.`id`, `users_credits_logs`.`target_id`, `users_credits_logs`.`admin_id`, `target`.`username` AS `target_username`, `owner`.`username` AS `owner_username`, `amount`, FROM_UNIXTIME(`date`) AS `date`, `users_credits_logs`.`reason` FROM `users_credits_logs` LEFT JOIN `users` AS `target` ON `target`.`id` = `users_credits_logs`.`target_id` LEFT JOIN `users` AS `owner` ON `owner`.`id` = `users_credits_logs`.`admin_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (Authorization::check('adv', 'edit_reguser')) {
- $rOwner = "
" . $rRow['owner_username'] . '';
- $rTarget = "
" . $rRow['target_username'] . '';
- } else {
- $rOwner = $rRow['owner_username'];
- $rTarget = $rRow['target_username'];
- }
- $rReturn['data'][] = array($rRow['id'], $rOwner, $rTarget, number_format($rRow['amount'], 0), $rRow['reason'], $rRow['date']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'client_logs') {
- if (Authorization::check('adv', 'client_request_log')) {
- $rOrder = array('`lines_logs`.`id`', '`lines`.`username`', '`streams`.`stream_display_name`', '`lines_logs`.`client_status`', '`lines_logs`.`user_agent`', '`lines_logs`.`ip`', '`lines_logs`.`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 7) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines_logs`.`client_status` LIKE ? OR `lines_logs`.`query_string` LIKE ? OR FROM_UNIXTIME(`date`) LIKE ? OR `lines_logs`.`user_agent` LIKE ? OR `lines_logs`.`ip` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `lines`.`username` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'] ?? '')) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range'] ?? '') - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`lines_logs`.`date` >= ? AND `lines_logs`.`date` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- $rWhere[] = '`lines_logs`.`client_status` = ?';
- $rWhereV[] = RequestManager::getAll()['filter'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines_logs` LEFT JOIN `streams` ON `streams`.`id` = `lines_logs`.`stream_id` LEFT JOIN `lines` ON `lines`.`id` = `lines_logs`.`user_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines_logs`.`id`, `lines_logs`.`user_id`, `lines_logs`.`stream_id`, `streams`.`stream_display_name`, `streams`.`type`, `lines`.`username`, `lines_logs`.`client_status`, `lines_logs`.`query_string`, `lines_logs`.`user_agent`, `lines_logs`.`ip`, FROM_UNIXTIME(`lines_logs`.`date`) AS `date` FROM `lines_logs` LEFT JOIN `streams` ON `streams`.`id` = `lines_logs`.`stream_id` LEFT JOIN `lines` ON `lines`.`id` = `lines_logs`.`user_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (Authorization::check('adv', 'edit_user')) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = $rRow['username'];
- }
- $rPermission = array(1 => 'streams', 2 => 'movies', 3 => 'streams', 4 => 'radio', 5 => 'series');
- $rURLs = array(1 => 'stream_view', 2 => 'stream_view', 3 => 'stream_view', 4 => 'stream_view');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- if ($rRow['type'] == 5) {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- }
- } else {
- $rChannel = $rRow['stream_display_name'];
- }
- $rExplode = explode(':', $rRow['ip']);
- $rIP = "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['ip'])) . '';
- $rReturn['data'][] = array($rRow['id'], $rUsername, $rChannel, $rClientFilters[$rRow['client_status']], $rRow['user_agent'], $rIP, $rRow['date']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'reg_user_logs') {
- if (Authorization::check('adv', 'reg_userlog')) {
- $rOrder = array('`users_logs`.`id`', '`users`.`username`', '`users_logs`.`log_id`', '`users_logs`.`type`, `users_logs`.`action`', '`users_logs`.`cost`', '`users_logs`.`credits_after`', '`users_logs`.`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`users`.`username` LIKE ? OR `users_logs`.`deleted_info` LIKE ? OR `users_logs`.`action` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'] ?? '')) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range'] ?? '') - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`users_logs`.`date` >= ? AND `users_logs`.`date` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'] ?? '')) {
- } else {
- $rWhere[] = '`users_logs`.`owner` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- $rWhere[] = '`users_logs`.`action` = ?';
- $rWhereV[] = RequestManager::getAll()['filter'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rPackages = getPackages();
- $rQuery = 'SELECT `users`.`username`, `users_logs`.`id`, `users_logs`.`owner`, `users_logs`.`type`, `users_logs`.`action`, `users_logs`.`log_id`, `users_logs`.`package_id`, `users_logs`.`cost`, `users_logs`.`credits_after`, `users_logs`.`date`, `users_logs`.`deleted_info` FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (Authorization::check('adv', 'edit_reguser')) {
- $rOwner = "
" . $rRow['username'] . '';
- } else {
- $rOwner = $rRow['username'];
- }
- $rDevice = array('line' => 'User Line', 'mag' => 'MAG Device', 'enigma' => 'Enigma2 Device', 'user' => 'Reseller')[$rRow['type']];
- $rText = '';
- switch ($rRow['action']) {
- case 'new':
- if ($rRow['package_id']) {
- $rText = 'Created New ' . $rDevice . ' with Package: ' . $rPackages[$rRow['package_id']]['package_name'];
- } else {
- $rText = 'Created New ' . $rDevice;
- }
- break;
- case 'extend':
- if ($rRow['package_id']) {
- $rText = 'Extended ' . $rDevice . ' with Package: ' . $rPackages[$rRow['package_id']]['package_name'];
- } else {
- $rText = 'Extended ' . $rDevice;
- }
- break;
- case 'convert':
- $rText = 'Converted Device to User Line';
- break;
- case 'edit':
- $rText = 'Edited ' . $rDevice;
- break;
- case 'enable':
- $rText = 'Enabled ' . $rDevice;
- break;
- case 'disable':
- $rText = 'Disabled ' . $rDevice;
- break;
- case 'delete':
- $rText = 'Deleted ' . $rDevice;
- break;
- case 'send_event':
- $rText = 'Sent Event to ' . $rDevice;
- break;
- case 'adjust_credits':
- $rText = 'Adjusted Credits by ' . $rRow['cost'];
- break;
- }
- $rLineInfo = null;
- switch ($rRow['type']) {
- case 'line':
- $rLine = UserRepository::getLineById($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['username'] . '';
- }
- break;
- case 'user':
- $rLine = UserRepository::getRegisteredUserById($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['username'] . '';
- }
- break;
- case 'mag':
- $rLine = getMag($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['mac'] . '';
- }
- break;
- case 'enigma':
- $rLine = getEnigma($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['mac'] . '';
- }
- break;
- }
- if ($rLineInfo) {
- } else {
- $rDeletedInfo = json_decode($rRow['deleted_info'], true);
- if (is_array($rDeletedInfo)) {
- if (isset($rDeletedInfo['mac'])) {
- $rLineInfo = "
" . $rDeletedInfo['mac'] . '';
- } else {
- $rLineInfo = "
" . $rDeletedInfo['username'] . '';
- }
- } else {
- $rLineInfo = "
DELETED";
- }
- }
- $rReturn['data'][] = array($rRow['id'], $rOwner, $rLineInfo, $rText, number_format($rRow['cost'], 0), number_format($rRow['credits_after'], 0), date($rSettings['datetime_format'], $rRow['date']));
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'stream_errors') {
- if (Authorization::check('adv', 'stream_errors')) {
- $rOrder = array('`streams_errors`.`id`', '`streams`.`stream_display_name`', '`servers`.`server_name`', '`streams_errors`.`error`', '`streams_errors`.`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`stream_display_name` LIKE ? OR `servers`.`server_name` LIKE ? OR FROM_UNIXTIME(`date`) LIKE ? OR `streams_errors`.`error` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'] ?? '')) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range'] ?? '') - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`streams_errors`.`date` >= ? AND `streams_errors`.`date` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= intval(RequestManager::getAll()['server'] ?? 0)) {
- } else {
- $rWhere[] = '`streams_errors`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_errors` LEFT JOIN `streams` ON `streams`.`id` = `streams_errors`.`stream_id` LEFT JOIN `servers` ON `servers`.`id` = `streams_errors`.`server_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams_errors`.`id`, `streams_errors`.`stream_id`, `streams`.`type`, `streams_errors`.`server_id`, `streams`.`stream_display_name`, `servers`.`server_name`, `streams_errors`.`error`, FROM_UNIXTIME(`streams_errors`.`date`) AS `date` FROM `streams_errors` LEFT JOIN `streams` ON `streams`.`id` = `streams_errors`.`stream_id` LEFT JOIN `servers` ON `servers`.`id` = `streams_errors`.`server_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rPermission = array(1 => 'streams', 2 => 'movies', 3 => 'streams', 4 => 'radio', 5 => 'series');
- $rURLs = array(1 => 'stream_view', 2 => 'stream_view', 3 => 'stream_view', 4 => 'stream_view');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- if ($rRow['type'] == 5) {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rChannel = "
" . $rRow['stream_display_name'] . '';
- }
- } else {
- $rChannel = $rRow['stream_display_name'];
- }
- $rReturn['data'][] = array($rRow['id'], $rChannel, $rRow['server_name'], $rRow['error'], $rRow['date']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'stream_unique') {
- if (Authorization::check('adv', 'fingerprint')) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false, '`active_count`', null);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 1';
- if (SettingsManager::getAll()['redis_handler']) {
- } else {
- $rWhere[] = '(SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `lines_live`.`hls_end` = 0) > 0';
- }
- if (0 >= strlen(RequestManager::getAll()['category'] ?? '')) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name`, `streams`.`category_id`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `lines_live`.`hls_end` = 0) AS `active_count` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, true, true);
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['active_count'] = ($rConnectionCount[$rRow['id']] ?: 0);
- }
- if ($rRow['active_count'] != 0) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rCategory, $rRow['active_count'], "
");
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- } else {
- $rReturn['recordsTotal']--;
- }
- }
- }
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'reg_users') {
- if (Authorization::check('adv', 'mng_regusers')) {
- $rOrder = array('`users`.`id`', '`users`.`username`', '`users`.`owner_id`', '`users`.`ip`', '`users`.`status`', '`users`.`member_group_id`', '`users`.`credits`', false, false, false, false, '`users`.`last_login`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 7) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`users`.`id` LIKE ? OR `users`.`username` LIKE ? OR `users`.`notes` LIKE ? OR FROM_UNIXTIME(`users`.`date_registered`) LIKE ? OR FROM_UNIXTIME(`users`.`last_login`) LIKE ? OR `users`.`email` LIKE ? OR `users`.`ip` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == -1) {
- $rWhere[] = '`users`.`status` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == -2) {
- $rWhere[] = '`users`.`status` = 0';
- } else {
- $rWhere[] = '`users`.`member_group_id` = ?';
- $rWhereV[] = RequestManager::getAll()['filter'];
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'] ?? '')) {
- } else {
- $rWhere[] = '`users`.`owner_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `users` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `users`.`member_group_id`, `users`.`id`, `users`.`status`, `users`.`notes`, `users`.`owner_id`, `users`.`credits`, `users`.`username`, `users`.`email`, `users`.`ip`, FROM_UNIXTIME(`users`.`date_registered`) AS `date_registered`, FROM_UNIXTIME(`users`.`last_login`) AS `last_login`, `users`.`status` FROM `users` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rUserInfo = $rOwnerInfo = $rUserIDs = $rOwnerIDs = array();
- $rRows = $db->get_rows();
- foreach ($rRows as $rRow) {
- $rUserIDs[] = $rRow['id'];
- if (!$rRow['owner_id']) {
- } else {
- $rOwnerIDs[] = $rRow['owner_id'];
- }
- $rUserInfo[$rRow['id']] = array('is_reseller' => 0, 'user_lines' => 0, 'mag_lines' => 0, 'e2_lines' => 0, 'user_count' => 0, 'group_name' => null);
- }
- if (0 >= count($rUserIDs)) {
- } else {
- $db->query('SELECT `users`.`id`, `users_groups`.`is_reseller`, `users_groups`.`group_name` FROM `users_groups` LEFT JOIN `users` ON `users_groups`.`group_id` = `users`.`member_group_id` WHERE `users`.`id` IN (' . implode(',', $rUserIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rUserInfo[$rRow['id']]['is_reseller'] = $rRow['is_reseller'];
- $rUserInfo[$rRow['id']]['group_name'] = $rRow['group_name'];
- }
- $db->query('SELECT `member_id`, COUNT(`id`) AS `user_lines` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserIDs) . ') AND `lines`.`is_mag` = 0 AND `lines`.`is_e2` = 0 GROUP BY `member_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rUserInfo[$rRow['member_id']]['user_lines'] = $rRow['user_lines'];
- }
- $db->query('SELECT `member_id`, COUNT(`id`) AS `mag_lines` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserIDs) . ') AND `lines`.`is_mag` = 1 AND `lines`.`is_e2` = 0 GROUP BY `member_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rUserInfo[$rRow['member_id']]['mag_lines'] = $rRow['mag_lines'];
- }
- $db->query('SELECT `member_id`, COUNT(`id`) AS `e2_lines` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserIDs) . ') AND `lines`.`is_mag` = 0 AND `lines`.`is_e2` = 1 GROUP BY `member_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rUserInfo[$rRow['member_id']]['e2_lines'] = $rRow['e2_lines'];
- }
- }
- if (0 >= count($rOwnerIDs)) {
- } else {
- $db->query('SELECT `id`, `username` FROM `users` WHERE `id` IN (' . implode(',', $rOwnerIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rOwnerInfo[$rRow['id']] = $rRow['username'];
- }
- }
- foreach ($rRows as $rRow) {
- if (isset($rOwnerInfo[$rRow['owner_id']])) {
- $rRow['owner_username'] = $rOwnerInfo[$rRow['owner_id']];
- } else {
- $rRow['owner_username'] = '';
- }
- $rRow = array_merge($rRow, $rUserInfo[$rRow['id']]);
- if (!$rIsAPI) {
- if ($rRow['status'] == 1) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- if ($rRow['last_login']) {
- } else {
- $rRow['last_login'] = 'NEVER';
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rRow['notes'])) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_reguser')) {
- } else {
- if ($rRow['is_reseller']) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- if ($rRow['status'] == 1) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
";
- }
- $rButtons .= '
';
- }
- if (0 < strlen($rRow['ip'])) {
- $rExplode = explode(':', $rRow['ip']);
- $rIP = "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['ip'])) . '';
- } else {
- $rIP = '';
- }
- if ($rRow['is_reseller']) {
- $rCredits = '
';
- } else {
- $rCredits = '
';
- }
- if (0 < $rRow['user_count']) {
- $rUserCount = '
';
- } else {
- $rUserCount = '
';
- }
- if (0 < $rRow['user_lines']) {
- $rLineCount = '
';
- } else {
- $rLineCount = '
';
- }
- if (0 < $rRow['mag_lines']) {
- $rMagCount = '
';
- } else {
- $rMagCount = '
';
- }
- if (0 < $rRow['e2_lines']) {
- $rE2Count = '
';
- } else {
- $rE2Count = '
';
- }
- if (!isset(RequestManager::getAll()['no_url'])) {
- $rReturn['data'][] = array("
" . $rRow['id'] . '', "
" . $rRow['username'] . '', "
" . $rRow['owner_username'] . '', $rIP, $rStatus, '
', $rCredits, $rUserCount, $rLineCount, $rMagCount, $rE2Count, $rRow['last_login'], $rButtons);
- } else {
- $rReturn['data'][] = array($rRow['id'], $rRow['username'], $rRow['owner_username'], $rIP, $rStatus, '
', $rCredits, $rUserCount, $rLineCount, $rMagCount, $rE2Count, $rRow['last_login'], $rButtons);
- }
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'asns') {
- if (Authorization::check('adv', 'block_isps')) {
- $rOrder = array('`blocked_asns`.`asn`', '`blocked_asns`.`isp`', '`blocked_asns`.`domain`', '`blocked_asns`.`country`', '`blocked_asns`.`num_ips`', '`blocked_asns`.`type`', '`blocked_asns`.`blocked`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 5) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`blocked_asns`.`asn` LIKE ? OR `blocked_asns`.`isp` LIKE ? OR `blocked_asns`.`domain` LIKE ? OR `blocked_asns`.`country` LIKE ? OR `blocked_asns`.`type` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- $rWhere[] = '`blocked_asns`.`blocked` = ?';
- $rWhereV[] = RequestManager::getAll()['filter'];
- }
- if (0 >= strlen(RequestManager::getAll()['type'] ?? '')) {
- } else {
- $rWhere[] = '`blocked_asns`.`type` = ?';
- $rWhereV[] = RequestManager::getAll()['type'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `blocked_asns` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `blocked_asns`.`id`, `blocked_asns`.`asn`, `blocked_asns`.`isp`, `blocked_asns`.`domain`, `blocked_asns`.`country`, `blocked_asns`.`num_ips`, `blocked_asns`.`type`, `blocked_asns`.`blocked` FROM `blocked_asns` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- if ($rRow['blocked']) {
- $rButtons .= '";
- } else {
- $rButtons .= '";
- }
- $rButtons .= '
';
- if ($rRow['blocked']) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- $rType = strtoupper($rRow['type']);
- $rReturn['data'][] = array($rRow['asn'], $rRow['isp'], $rRow['domain'], '
 . '.png)
', number_format($rRow['num_ips'], 0), $rType, $rStatus, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'series') {
- if (Authorization::check('adv', 'series') || Authorization::check('adv', 'mass_sedits')) {
- $rCategories = CategoryService::getAllByType('series');
- $rOrder = array('`streams_series`.`id`', '`streams_series`.`cover`', '`streams_series`.`title`', '`streams_series`.`category_id`', '`latest_season`', '`episode_count`', false, '`streams_series`.`release_date`', '`streams_series`.`last_modified`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams_series`.`id` LIKE ? OR `streams_series`.`title` LIKE ? OR `streams_series`.`release_date` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'] ?? '')) {
- } else {
- if (RequestManager::getAll()['category'] == -1) {
- $rWhere[] = '(`streams_series`.`tmdb_id` = 0 OR `streams_series`.`tmdb_id` IS NULL)';
- } else {
- if (RequestManager::getAll()['category'] == -2) {
- $rWhere[] = "(`streams_series`.`category_id` = '[]' OR `streams_series`.`category_id` IS NULL)";
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams_series`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection . ', `streams_series`.`id` ASC';
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_series` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams_series`.`id`, `streams_series`.`year`, `streams_series`.`rating`, `streams_series`.`cover`, `streams_series`.`title`, `streams_series`.`category_id`, `streams_series`.`tmdb_id`, `streams_series`.`release_date`, `streams_series`.`last_modified`, (SELECT MAX(`season_num`) FROM `streams_episodes` WHERE `series_id` = `streams_series`.`id`) AS `latest_season`, (SELECT COUNT(*) FROM `streams_episodes` WHERE `series_id` = `streams_series`.`id`) AS `episode_count` FROM `streams_series` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '
';
- } else {
- $rButtons = '
';
- if (!Authorization::check('adv', 'add_episode')) {
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'episodes')) {
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_series')) {
- } else {
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t" . '
";
- }
- $rButtons .= '
';
- }
- if (0 < $rRow['latest_season']) {
- $rRow['latest_season'] = "
';
- } else {
- $rRow['latest_season'] = "
";
- }
- if (0 < $rRow['episode_count']) {
- if (Authorization::check('adv', 'episodes')) {
- $rRow['episode_count'] = "
';
- } else {
- $rRow['episode_count'] = "
';
- }
- } else {
- $rRow['episode_count'] = "
";
- }
- if ($rRow['last_modified'] == 0) {
- $rRow['last_modified'] = 'Never';
- } else {
- $rRow['last_modified'] = date($rSettings['datetime_format'], $rRow['last_modified']);
- }
- if (!$rRow['release_date']) {
- } else {
- $rRow['release_date'] = date($rSettings['date_format'], strtotime($rRow['release_date']));
- }
- if (0 < $rRow['tmdb_id']) {
- $rTMDB = '
';
- } else {
- $rTMDB = '
';
- }
- if (0 < strlen($rRow['cover']) && SettingsManager::getAll()['show_images']) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- if (Authorization::check('adv', 'episodes')) {
- $rID = "
" . $rRow['id'] . '';
- $rTitle = "
" . $rRow['title'] . '';
- } else {
- $rID = $rRow['id'];
- $rTitle = '
' . $rRow['title'] . '';
- }
- $rRatingText = '';
- if (!$rRow['rating']) {
- } else {
- $rStarRating = round($rRow['rating']) / 2;
- $rFullStars = floor($rStarRating);
- $rHalfStar = 0 < $rStarRating - $rFullStars;
- $rEmpty = 5 - ($rFullStars + (($rHalfStar ? 1 : 0)));
- if (0 >= $rFullStars) {
- } else {
- foreach (range(1, $rFullStars) as $i) {
- $rRatingText .= "
";
- }
- }
- if (!$rHalfStar) {
- } else {
- $rRatingText .= "
";
- }
- if (0 >= $rEmpty) {
- } else {
- foreach (range(1, $rEmpty) as $i) {
- $rRatingText .= "
";
- }
- }
- }
- $rYear = ($rRow['year'] ? '
' . $rRow['year'] . ' ' : '');
- $rTitle .= "
" . $rYear . $rRatingText . '';
- $rReturn['data'][] = array($rID, $rImage, $rTitle, $rCategory, $rRow['latest_season'], $rRow['episode_count'], $rTMDB, $rRow['release_date'], $rRow['last_modified'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'episodes') {
- if (Authorization::check('adv', 'episodes') || Authorization::check('adv', 'mass_sedits')) {
- $rOrder = array('`streams`.`id`', false, '`streams`.`stream_display_name`', '`server_name`', '`clients`', '`streams_servers`.`stream_started`', false, false, '`streams_servers`.`bitrate`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 5';
- $rDuplicates = false;
- if (isset(RequestManager::getAll()['stream_id'])) {
- $rWhere[] = '`streams`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (isset(RequestManager::getAll()['source_id'])) {
- $rWhere[] = 'MD5(`streams`.`stream_source`) = ?';
- $rWhereV[] = RequestManager::getAll()['source_id'];
- $rOrderBy = 'ORDER BY `streams_servers`.`server_stream_id` ASC';
- } else {
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 5) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams_series`.`title` LIKE ? OR `streams`.`notes` LIKE ? OR `streams_servers`.`current_source` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['series'] ?? '')) {
- } else {
- $rWhere[] = '`streams_series`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['series'];
- }
- if (!isset(RequestManager::getAll()['refresh'])) {
- } else {
- $rWhere = array('`streams`.`id` IN (' . implode(',', array_map('intval', explode(',', RequestManager::getAll()['refresh']))) . ')');
- $rWhereV = array();
- $rStart = 0;
- $rLimit = 1000;
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 0 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`pid` > 0 AND `streams_servers`.`to_analyze` = 1 AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND `streams_servers`.`stream_status` = 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`streams`.`direct_source` = 0 AND (`streams_servers`.`pid` IS NULL OR `streams_servers`.`pid` <= 0) AND `streams_servers`.`stream_status` <> 1)';
- } else {
- if (RequestManager::getAll()['filter'] == 5) {
- $rWhere[] = '`streams`.`direct_source` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 6) {
- $rWhere[] = '`streams`.`id` IN (SELECT MIN(`id`) FROM `streams` WHERE `type` = 5 GROUP BY `stream_source` HAVING COUNT(`stream_source`) > 1)';
- $rDuplicates = true;
- } else {
- if (RequestManager::getAll()['filter'] != 7) {
- } else {
- $rWhere[] = '`streams`.`transcode_profile_id` > 0';
- }
- }
- }
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['audio'])) {
- } else {
- if (RequestManager::getAll()['audio'] == -1) {
- $rWhere[] = '`streams_servers`.`audio_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`audio_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['audio'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['video'])) {
- } else {
- if (RequestManager::getAll()['video'] == -1) {
- $rWhere[] = '`streams_servers`.`video_codec` IS NULL';
- } else {
- $rWhere[] = '`streams_servers`.`video_codec` = ?';
- $rWhereV[] = RequestManager::getAll()['video'];
- }
- }
- if (0 >= strlen(RequestManager::getAll()['resolution'])) {
- } else {
- $rWhere[] = '`streams_servers`.`resolution` = ?';
- $rWhereV[] = (intval(RequestManager::getAll()['resolution']) ?: null);
- }
- if (0 < intval(RequestManager::getAll()['server'] ?? 0)) {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- } else {
- if (intval(RequestManager::getAll()['server'] ?? 0) != -1) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` IS NULL';
- }
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- }
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (isset(RequestManager::getAll()['single'])) {
- $rSettings['streams_grouped'] = 0;
- } else {
- if (!isset(RequestManager::getAll()['grouped'])) {
- } else {
- $rSettings['streams_grouped'] = 1;
- }
- }
- $rReturn['recordsTotal'] = 0;
- if ($rSettings['streams_grouped'] == 1) {
- $rCountQuery = 'SELECT COUNT(DISTINCT(`streams`.`id`)) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ';';
- } else {
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ';';
- }
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams_servers`.`to_analyze`, `streams`.`movie_properties`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams_series`.`title`, `streams_series`.`seasons`, `streams_series`.`id` AS `sid`, `streams_episodes`.`season_num` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` AND `streams_servers`.`parent_id` IS NULL LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ' GROUP BY `streams`.`id` ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- } else {
- $rQuery = 'SELECT `streams`.`id`, MD5(`streams`.`stream_source`) AS `source`, `streams_servers`.`to_analyze`, `streams`.`movie_properties`, `streams`.`target_container`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`notes`, `streams`.`direct_source`, `streams`.`direct_proxy`, `streams_servers`.`pid`, `streams_servers`.`monitor_pid`, `streams_servers`.`stream_status`, `streams_servers`.`stream_started`, `streams_servers`.`stream_info`, `streams_servers`.`current_source`, `streams_servers`.`bitrate`, `streams_servers`.`progress_info`, `streams_servers`.`on_demand`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name`, (SELECT COUNT(*) FROM `lines_live` WHERE `lines_live`.`server_id` = `streams_servers`.`server_id` AND `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0) AS `clients`, `streams_series`.`title`, `streams_series`.`seasons`, `streams_series`.`id` AS `sid`, `streams_episodes`.`season_num` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- }
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rServerCount = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = $rRow['id'];
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, COUNT(`server_stream_id`) AS `count` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ') GROUP BY `stream_id`;');
- foreach ($db->get_rows() as $rRow) {
- $rServerCount[$rRow['stream_id']] = $rRow['count'];
- }
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped']) {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, true, true);
- } else {
- $rConnectionCount = ConnectionTracker::getStreamConnections($rStreamIDs, false, false);
- }
- }
- if (!$rDuplicates) {
- } else {
- $rDuplicateCount = array();
- $db->query('SELECT MD5(`stream_source`) AS `source`, COUNT(`stream_source`) AS `count` FROM `streams` WHERE `stream_source` IN (SELECT `stream_source` FROM `streams` WHERE `id` IN (' . implode(',', array_map('intval', $rStreamIDs)) . ')) GROUP BY `stream_source` HAVING COUNT(`stream_source`) > 1;');
- foreach ($db->get_rows() as $rRow) {
- $rDuplicateCount[$rRow['source']] = $rRow['count'];
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- if ($rSettings['streams_grouped'] == 1) {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- } else {
- $rRow['clients'] = (count($rConnectionCount[$rRow['id']][$rRow['server_id']]) ?: 0);
- }
- }
- if (!$rIsAPI) {
- $rSeriesName = $rRow['title'] . ' - Season ' . $rRow['season_num'];
- $rStreamName = '
' . $rRow['stream_display_name'] . "" . $rSeriesName . '';
- if ($rRow['server_name']) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- if (!($rSettings['streams_grouped'] && 1 < $rServerCount[$rRow['id']])) {
- } else {
- $rServerName .= "
';
- }
- if ($rServers[$rRow['server_id']]['last_status'] == 1) {
- } else {
- $rServerName .= "
Uptime cannot be confirmed.\" type='button' class='tooltip btn btn-danger btn-xs waves-effect waves-light'>
";
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- if ($rSettings['streams_grouped']) {
- } else {
- $rStreamSource = "
" . parse_url($rRow['current_source'])['host'] . '';
- $rServerName .= $rStreamSource;
- }
- $rUptime = 0;
- $rActualStatus = 0;
- if (intval($rRow['direct_source']) == 1) {
- if (intval($rRow['direct_proxy']) == 1) {
- $rActualStatus = 5;
- } else {
- $rActualStatus = 3;
- }
- } else {
- if (!is_null($rRow['pid']) && 0 < $rRow['pid']) {
- if ($rRow['to_analyze'] == 1) {
- $rActualStatus = 2;
- } else {
- if ($rRow['stream_status'] == 1) {
- $rActualStatus = 4;
- } else {
- $rActualStatus = 1;
- }
- }
- } else {
- $rActualStatus = 0;
- }
- }
- if ($rRow['server_id']) {
- } else {
- $rRow['server_id'] = 0;
- }
- if ($rSettings['streams_grouped'] != 1) {
- } else {
- $rRow['server_id'] = -1;
- }
- if (Authorization::check('adv', 'live_connections')) {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- } else {
- if (0 < $rRow['clients']) {
- $rClients = "
';
- } else {
- $rClients = "
";
- }
- }
- if (SettingsManager::getAll()['group_buttons']) {
- $rButtons = '';
- if (0 >= strlen($rRow['notes'])) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- } else {
- $rButtons = '
';
- if ((isset(RequestManager::getAll()['single']) || isset(RequestManager::getAll()['simple'])) && Authorization::check('adv', 'edit_episode')) {
- if (intval($rActualStatus) == 1) {
- $rButtons .= '
";
- } else {
- if (intval($rActualStatus) == 3) {
- $rButtons .= '
';
- } else {
- if (intval($rActualStatus) == 2) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- }
- }
- if (!isset(RequestManager::getAll()['single'])) {
- } else {
- $rButtons .= '
";
- }
- } else {
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (!Authorization::check('adv', 'edit_episode')) {
- } else {
- if (intval($rActualStatus) == 1) {
- $rButtons .= '
";
- } else {
- if (intval($rActualStatus) == 3) {
- $rButtons .= '
';
- } else {
- if (intval($rActualStatus) == 2) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- }
- }
- $rButtons .= '
' . "\r\n\t\t\t\t\t\t\t" . '
";
- }
- }
- $rButtons .= '
';
- }
- if ($rDuplicates) {
- $rDupeCount = ($rDuplicateCount[$rRow['source']] - 1 ?: 0);
- $rStreamInfoText = "
Duplicate of " . $rDupeCount . ' other episode' . (($rDupeCount == 1 ? '' : 's')) . '';
- } else {
- $rStreamInfoText = "
";
- $rStreamInfo = json_decode($rRow['stream_info'], true);
- if ($rActualStatus != 1) {
- } else {
- if (isset($rStreamInfo['codecs']['video'])) {
- } else {
- $rStreamInfo['codecs']['video'] = array('width' => '?', 'height' => '?', 'codec_name' => 'N/A', 'r_frame_rate' => '--');
- }
- if (isset($rStreamInfo['codecs']['audio'])) {
- } else {
- $rStreamInfo['codecs']['audio'] = array('codec_name' => 'N/A');
- }
- if ($rRow['bitrate'] != 0) {
- } else {
- $rRow['bitrate'] = '?';
- }
- $rStreamInfoText = "
" . "\r\n\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t\t" . "| " . number_format($rRow['bitrate'], 0) . ' Kbps | ' . "\r\n\t\t\t\t\t\t\t\t\t" . " | " . "\r\n\t\t\t\t\t\t\t\t\t" . " | " . "\r\n\t\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t\t\t\t" . "| " . $rStreamInfo['codecs']['video']['width'] . ' x ' . $rStreamInfo['codecs']['video']['height'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t\t" . '' . $rStreamInfo['codecs']['video']['codec_name'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t\t" . '' . $rStreamInfo['codecs']['audio']['codec_name'] . ' | ' . "\r\n\t\t\t\t\t\t\t\t" . '
' . "\r\n\t\t\t\t\t\t\t" . '' . "\r\n\t\t\t\t\t\t" . '
';
- }
- }
- if (Authorization::check('adv', 'player')) {
- if (intval($rActualStatus) == 1 || $rActualStatus == 3) {
- if (empty($rStreamInfo['codecs']['video']['codec_name']) || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'H264' || strtoupper($rStreamInfo['codecs']['video']['codec_name']) == 'N/A') {
- $rPlayer = '
";
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- } else {
- $rPlayer = '
';
- }
- $rImage = '';
- $rProperties = json_decode($rRow['movie_properties'], true);
- if (!(0 < strlen($rProperties['movie_image']) && SettingsManager::getAll()['show_images'])) {
- } else {
- $rImage = "

";
- }
- $rID = $rRow['id'];
- if ($rSettings['streams_grouped'] || 1 >= $rServerCount[$rRow['id']]) {
- } else {
- $rID .= '-' . $rRow['server_id'];
- }
- $rReturn['data'][] = array("
" . $rID . '', $rImage, "
" . $rStreamName . '', $rServerName, $rClients, $rVODStatusArray[$rActualStatus], $rButtons, $rPlayer, $rStreamInfoText);
- } else {
- unset($rReturn['source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'backups') {
- if (Authorization::check('adv', 'database')) {
- $rBackups = array_reverse(getBackups());
- $rRemoteBackups = array();
- if (0 >= strlen($rSettings['dropbox_token'])) {
- } else {
- foreach (array_reverse(getRemoteBackups()) as $rBackup) {
- $rRemoteBackups[$rBackup['name']] = $rBackup;
- }
- }
- $rReturn = array('draw' => intval(RequestManager::getAll()['draw']), 'recordsTotal' => count($rBackups), 'recordsFiltered' => count($rBackups), 'data' => array());
- $rLocalFiles = array();
- foreach ($rBackups as $rBackup) {
- $rButtons = "
" . "\r\n" . "
";
- $rLocal = "
";
- if (isset($rRemoteBackups[$rBackup['filename']])) {
- $rRemote = "
";
- unset($rRemoteBackups[$rBackup['filename']]);
- } else {
- if (file_exists(MAIN_HOME . 'backups/' . $rBackup['filename'] . '.error')) {
- $rRemote = "
";
- } else {
- if (file_exists(MAIN_HOME . 'backups/' . $rBackup['filename'] . '.uploading') && time() - filemtime(MAIN_HOME . 'backups/' . $rBackup['filename'] . '.uploading') < 600) {
- $rRemote = "
";
- } else {
- $rRemote = "
";
- }
- }
- }
- $rLocalFiles[] = $rBackup['filename'];
- $rReturn['data'][] = array(date($rSettings['datetime_format'], strtotime($rBackup['date'])), $rBackup['filename'], ceil($rBackup['filesize'] / 1024 / 1024) . ' MB', $rLocal, $rRemote, $rButtons);
- }
- foreach ($rRemoteBackups as $rBackup) {
- $rButtons = "
" . "\r\n" . "
";
- if (in_array($rBackup['name'], $rLocalFiles)) {
- $rLocal = "
";
- } else {
- $rLocal = "
";
- }
- $rRemote = "
";
- $rReturn['data'][] = array(date($rSettings['datetime_format'], $rBackup['time']), $rBackup['name'], ceil($rBackup['size'] / 1024 / 1024) . ' MB', $rLocal, $rRemote, $rButtons);
- }
- echo json_encode($rReturn);
- exit();
- } else {
- exit();
- }
-}
-if ($rType == 'watch_output') {
- if (Authorization::check('adv', 'folder_watch_output')) {
- $rOrder = array('`watch_logs`.`id`', '`watch_logs`.`type`', '`watch_logs`.`server_id`', '`watch_logs`.`filename`', '`watch_logs`.`status`', '`watch_logs`.`dateadded`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`watch_logs`.`id` LIKE ? OR `watch_logs`.`filename` LIKE ? OR `watch_logs`.`dateadded` LIKE ?)';
- }
- if (0 >= intval(RequestManager::getAll()['server'] ?? 0)) {
- } else {
- $rWhere[] = '`watch_logs`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- }
- if (0 >= strlen(RequestManager::getAll()['type'] ?? '')) {
- } else {
- $rWhere[] = '`watch_logs`.`type` = ?';
- $rWhereV[] = RequestManager::getAll()['type'];
- }
- if (0 >= strlen(RequestManager::getAll()['status'] ?? '')) {
- } else {
- $rWhere[] = '`watch_logs`.`status` = ?';
- $rWhereV[] = RequestManager::getAll()['status'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `watch_logs` LEFT JOIN `servers` ON `servers`.`id` = `watch_logs`.`server_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `watch_logs`.`id`, `watch_logs`.`type`, `watch_logs`.`server_id`, `servers`.`server_name`, `watch_logs`.`filename`, `watch_logs`.`status`, `watch_logs`.`stream_id`, `watch_logs`.`dateadded` FROM `watch_logs` LEFT JOIN `servers` ON `servers`.`id` = `watch_logs`.`server_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- if (0 >= $rRow['stream_id']) {
- } else {
- if ($rRow['type'] == 1) {
- if (!Authorization::check('adv', 'edit_movie')) {
- } else {
- $rButtons = '
';
- }
- } else {
- if (!Authorization::check('adv', 'edit_episode')) {
- } else {
- $rButtons = '
';
- }
- }
- }
- if (!(1 < $rRow['status'] && $rRow['type'] == 1)) {
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
";
- $rButtons .= '
';
- if (Authorization::check('adv', 'servers')) {
- $rServer = "
" . $rRow['server_name'] . '';
- } else {
- $rServer = $rRow['server_name'];
- }
- $rReturn['data'][] = array($rRow['id'], array(1 => 'Movies', 2 => 'Series')[$rRow['type']], $rServer, $rRow['filename'], $rWatchStatusArray[$rRow['status']], $rRow['dateadded'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'mysql_syslog') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'panel_logs')) {
- $rOrder = array('`mysql_syslog`.`date`', '`servers`.`server_name`', '`mysql_syslog`.`type`', '`mysql_syslog`.`error`', '`mysql_syslog`.`ip`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`mysql_syslog`.`ip` LIKE ? OR `mysql_syslog`.`type` LIKE ? OR `mysql_syslog`.`error` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `mysql_syslog` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rBlocked = array();
- $db->query('SELECT `ip` FROM `blocked_ips`;');
- foreach ($db->get_rows() as $rRow) {
- $rBlocked[] = $rRow['ip'];
- }
- $rQuery = 'SELECT `mysql_syslog`.`id`, `mysql_syslog`.`server_id`, `servers`.`server_name`, `mysql_syslog`.`type`, `mysql_syslog`.`error`, `mysql_syslog`.`ip`, `mysql_syslog`.`date` FROM `mysql_syslog` LEFT JOIN `servers` ON `servers`.`id` = `mysql_syslog`.`server_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['ip'] != '127.0.0.1') {
- } else {
- $rRow['ip'] = 'localhost';
- }
- if (0 < strlen($rRow['ip']) && $rRow['ip'] != 'localhost') {
- if (!in_array($rRow['ip'], $rBlocked)) {
- $rButtons = "
";
- } else {
- $rButtons = '
';
- }
- $rExplode = explode(':', $rRow['ip']);
- $rIP = "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['ip'])) . '';
- } else {
- $rButtons = '
';
- $rIP = 'localhost';
- }
- $rReturn['data'][] = array(date($rSettings['datetime_format'], $rRow['date']), "
" . $rRow['server_name'] . '', $rRow['type'], $rRow['error'], $rIP, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'panel_logs') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'panel_logs')) {
- $rOrder = array('`panel_logs`.`date`', '`servers`.`server_name`', '`panel_logs`.`type`', '`panel_logs`.`log_message`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`panel_logs`.`log_message` LIKE ? OR `panel_logs`.`log_extra` LIKE ? OR `panel_logs`.`type` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `panel_logs` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `panel_logs`.`id`, `panel_logs`.`date`, `panel_logs`.`server_id`, `servers`.`server_name`, `panel_logs`.`type`, `panel_logs`.`log_message`, `panel_logs`.`log_extra` FROM `panel_logs` LEFT JOIN `servers` ON `servers`.`id` = `panel_logs`.`server_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rReturn['data'][] = array(date($rSettings['datetime_format'], $rRow['date']), "
" . $rRow['server_name'] . '', strtoupper($rRow['type']), $rRow['log_message'] . (($rRow['log_extra'] ? '
' . $rRow['log_extra'] : '')));
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'login_logs') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'login_logs')) {
- $rOrder = array('`login_logs`.`date`', '`login_logs`.`type`', '`login_logs`.`status`', '`users`.`username`', '`access_codes`.`code`', '`login_logs`.`login_ip`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`login_logs`.`login_ip` LIKE ? OR `login_logs`.`status` LIKE ? OR `users`.`username` LIKE ? OR `access_codes`.`code` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `login_logs` LEFT JOIN `users` ON `users`.`id` = `login_logs`.`user_id` LEFT JOIN `access_codes` ON `access_codes`.`id` = `login_logs`.`access_code` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rBlocked = array();
- $db->query('SELECT `ip` FROM `blocked_ips`;');
- foreach ($db->get_rows() as $rRow) {
- $rBlocked[] = $rRow['ip'];
- }
- $rQuery = 'SELECT `login_logs`.`id`, `login_logs`.`type`, `login_logs`.`access_code`, `access_codes`.`code`, `login_logs`.`user_id`, `users`.`username`, `login_logs`.`status`, `login_logs`.`login_ip`, `login_logs`.`date` FROM `login_logs` LEFT JOIN `users` ON `users`.`id` = `login_logs`.`user_id` LEFT JOIN `access_codes` ON `access_codes`.`id` = `login_logs`.`access_code` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (0 < strlen($rRow['login_ip'])) {
- if (!in_array($rRow['login_ip'], $rBlocked)) {
- $rButtons = "
";
- } else {
- $rButtons = '
';
- }
- $rExplode = explode(':', $rRow['ip']);
- $rIP = "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['ip'])) . '';
- } else {
- $rButtons = '
';
- $rIP = '';
- }
- $rReturn['data'][] = array(date($rSettings['datetime_format'], $rRow['date']), $rRow['type'], $rRow['status'], '
' . $rRow['username'] . '', $rRow['code'], $rIP, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'queue') {
- if ($rPermissions['is_admin'] && (Authorization::check('adv', 'movies') || Authorization::check('adv', 'episodes') || Authorization::check('adv', 'series'))) {
- $rOrder = array('`queue`.`id`', '`streams`.`stream_display_name`', '`servers`.`server_name`', '`queue`.`pid`', '`queue`.`added`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`stream_display_name` LIKE ? OR `servers`.`server_name` LIKE ? OR `streams`.`id` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `queue` LEFT JOIN `servers` ON `servers`.`id` = `queue`.`server_id` LEFT JOIN `streams` ON `streams`.`id` = `queue`.`stream_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `queue`.*, `servers`.`server_name`, `streams`.`type`, `streams`.`stream_display_name` FROM `queue` LEFT JOIN `servers` ON `servers`.`id` = `queue`.`server_id` LEFT JOIN `streams` ON `streams`.`id` = `queue`.`stream_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rPosition = $rStart + 1;
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- $rPermission = array(2 => 'movies', 5 => 'series');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- $rStream = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rStream = $rRow['stream_display_name'];
- }
- if (0 < $rRow['pid']) {
- $rStatus = '
';
- $rButtons = "
";
- } else {
- $rStatus = '
';
- $rButtons = "
";
- }
- $rReturn['data'][] = array($rPosition, $rStream, $rServerName, $rStatus, date($rSettings['datetime_format'], $rRow['added']), $rButtons);
- $rPosition++;
- } else {
- $rRow['position'] = $rPosition;
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'restream_logs') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'restream_logs')) {
- $rOrder = array('`detect_restream_logs`.`id`', '`lines`.`username`', '`streams`.`stream_display_name`', '`detect_restream_logs`.`ip`', '`detect_restream_logs`.`time`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`detect_restream_logs`.`ip` LIKE ? OR `lines`.`username` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `detect_restream_logs` LEFT JOIN `lines` ON `lines`.`id` = `detect_restream_logs`.`user_id` LEFT JOIN `streams` ON `streams`.`id` = `detect_restream_logs`.`stream_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rBlocked = array();
- $db->query('SELECT `ip` FROM `blocked_ips`;');
- foreach ($db->get_rows() as $rRow) {
- $rBlocked[] = $rRow['ip'];
- }
- $rQuery = 'SELECT `detect_restream_logs`.`id`, `detect_restream_logs`.`user_id`, `detect_restream_logs`.`stream_id`, `detect_restream_logs`.`ip`, `detect_restream_logs`.`time`, `lines`.`username`, `streams`.`stream_display_name`, `streams`.`type` FROM `detect_restream_logs` LEFT JOIN `lines` ON `lines`.`id` = `detect_restream_logs`.`user_id` LEFT JOIN `streams` ON `streams`.`id` = `detect_restream_logs`.`stream_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (0 < strlen($rRow['ip'])) {
- if (!in_array($rRow['ip'], $rBlocked)) {
- $rButtons = "
";
- } else {
- $rButtons = '
';
- }
- $rExplode = explode(':', $rRow['ip']);
- $rIP = "
" . ((1 < count($rExplode) ? implode(':', array_slice($rExplode, 0, 4)) . ':
' . implode(':', array_slice($rExplode, 4, 8)) : $rRow['ip'])) . '';
- } else {
- $rButtons = '
';
- $rIP = '';
- }
- $rPermission = array(1 => 'streams', 2 => 'movies', 3 => 'streams', 4 => 'radio', 5 => 'series');
- $rURLs = array(1 => 'stream_view', 2 => 'stream_view', 3 => 'stream_view', 4 => 'stream_view');
- if (Authorization::check('adv', $rPermission[$rRow['type']])) {
- if ($rRow['type'] == 5) {
- $rStream = "
" . $rRow['stream_display_name'] . '';
- } else {
- $rStream = "
" . $rRow['stream_display_name'] . '';
- }
- } else {
- $rStream = $rRow['stream_display_name'];
- }
- if (Authorization::check('adv', 'edit_user')) {
- $rLine = '
' . $rRow['username'] . '';
- } else {
- $rLine = $rRow['username'];
- }
- $rReturn['data'][] = array($rRow['id'], $rLine, $rStream, $rIP, date($rSettings['datetime_format'], $rRow['date']), $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'mag_events') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'manage_events')) {
- $rOrder = array('`mag_events`.`send_time`', '`mag_devices`.`mac`', '`mag_events`.`event`', '`mag_events`.`msg`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`mag_devices`.`mac` LIKE ? OR `mag_events`.`event` LIKE ? OR `mag_events`.`msg` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `mag_events` LEFT JOIN `mag_devices` ON `mag_devices`.`mag_id` = `mag_events`.`mag_device_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `mag_events`.`id`, `mag_events`.`send_time`, `mag_devices`.`mac`, `mag_events`.`event`, `mag_events`.`msg`, `mag_events`.`mag_device_id` FROM `mag_events` LEFT JOIN `mag_devices` ON `mag_devices`.`mag_id` = `mag_events`.`mag_device_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
";
- $rReturn['data'][] = array(date($rSettings['datetime_format'], $rRow['send_time']), $rRow['mac'], $rRow['event'], $rRow['msg'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'bouquets_streams') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'bouquets')) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false, false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '(`type` = 1 OR `type` = 3)';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name`, `streams`.`category_id` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category_id'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category_id'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rButtons = '
" . "\r\n" . '
";
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rCategory, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'bouquets_vod') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'bouquets')) {
- $rCategories = CategoryService::getAllByType('movie');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false, false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`type` = 2';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name`, `streams`.`category_id` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category_id'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category_id'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rButtons = '
" . "\r\n" . '
";
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rCategory, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'bouquets_series') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'bouquets')) {
- $rCategories = CategoryService::getAllByType('series');
- $rOrder = array('`streams_series`.`id`', '`streams_series`.`title`', false, false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams_series`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams_series`.`id` LIKE ? OR `streams_series`.`title` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_series` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams_series`.`id`, `streams_series`.`title`, `streams_series`.`category_id` FROM `streams_series` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category_id'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category_id'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rButtons = '
" . "\r\n" . '
";
- $rReturn['data'][] = array($rRow['id'], $rRow['title'], $rCategory, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'bouquets_radios') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'bouquets')) {
- $rCategories = CategoryService::getAllByType('radio');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false, false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`type` = 4';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name`, `streams`.`category_id` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category_id'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category_id'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rButtons = '
" . "\r\n" . '
";
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rCategory, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'streams_short') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'categories')) {
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '(`type` = 1 OR `type` = 3)';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'movies_short') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'categories')) {
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`type` = 2';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'radios_short') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'categories')) {
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`type` = 4';
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'series_short') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'categories')) {
- $rOrder = array('`streams_series`.`id`', '`streams_series`.`title`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- if (!(isset(RequestManager::getAll()['category_id']) && 0 < intval(RequestManager::getAll()['category_id']))) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams_series`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category_id'];
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams_series`.`id` LIKE ? OR `streams_series`.`title` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_series` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams_series`.`id`, `streams_series`.`title` FROM `streams_series` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
';
- $rReturn['data'][] = array($rRow['id'], $rRow['title'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'vod_selection') {
- if ($rPermissions['is_admin'] && Authorization::check('adv', 'create_channel')) {
- $rCategories = CategoryService::getAllByType('movie');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_display_name`', '`streams_series`.`title`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`stream_source` LIKE ?';
- $rWhereV[] = '%s:' . intval(RequestManager::getAll()['server_id'] ?? 0) . ':%';
- if (isset(RequestManager::getAll()['category_id']) && 0 < strlen(RequestManager::getAll()['category_id'])) {
- $rSplit = explode(':', RequestManager::getAll()['category_id']);
- if (intval($rSplit[0]) == 0) {
- $rWhere[] = "(`streams`.`type` = 2 AND JSON_CONTAINS(`streams`.`category_id`, ?, '\$'))";
- $rWhereV[] = $rSplit[1];
- } else {
- $rWhere[] = '(`streams`.`type` = 5 AND `streams`.`series_no` = ?)';
- $rWhereV[] = $rSplit[1];
- }
- } else {
- $rWhere[] = '(`streams`.`type` = 2 OR `streams`.`type` = 5)';
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `streams_series`.`title` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams`.`series_no` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `streams`.`stream_display_name`, `streams`.`category_id`, `streams_series`.`title` FROM `streams` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams`.`series_no` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rButtons = '
' . "\r\n" . '
';
- if (0 < strlen($rRow['title'])) {
- $rCategory = $rRow['title'];
- } else {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen($rSplit[1])) {
- $rCategory = ($rCategories[intval($rSplit[1])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- }
- $rReturn['data'][] = array($rRow['id'], $rRow['stream_display_name'], $rCategory, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'provider_streams') {
- $rOrder = array('`providers`.`name`', '`providers_streams`.`stream_icon`', '`providers_streams`.`stream_display_name`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`providers`.`enabled` = 1 AND `providers`.`status` = 1';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 4) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`providers`.`name` LIKE ? OR `providers`.`ip` LIKE ? OR `providers_streams`.`stream_display_name` LIKE ? OR `providers_streams`.`stream_id` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['type'] ?? '')) {
- } else {
- $rWhere[] = '`providers_streams`.`type` = ?';
- $rWhereV[] = RequestManager::getAll()['type'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `providers_streams` LEFT JOIN `providers` ON `providers`.`id` = `providers_streams`.`provider_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `providers`.`id`,`providers_streams`.`type`,`providers`.`username`, `providers`.`password`, `providers`.`ssl`, `providers`.`legacy`, `providers`.`hls`, `providers`.`ip`, `providers`.`port`, `providers`.`name`, `providers`.`data`, `providers_streams`.`stream_id`, `providers_streams`.`category_array`, `providers_streams`.`stream_display_name`, `providers_streams`.`stream_icon`,`providers_streams`.`channel_id` FROM `providers_streams` LEFT JOIN `providers` ON `providers`.`id` = `providers_streams`.`provider_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['type'] == 'live') {
- $rStreamURL = (($rRow['ssl'] ? 'https' : 'http')) . '://' . $rRow['ip'] . ':' . $rRow['port'] . '/live/' . $rRow['username'] . '/' . $rRow['password'] . '/' . $rRow['stream_id'] . (($rRow['hls'] ? '.m3u8' : ($rRow['legacy'] ? '.ts' : '')));
- $rButtons = "
";
- } else {
- $rStreamURL = (($rRow['ssl'] ? 'https' : 'http')) . '://' . $rRow['ip'] . ':' . $rRow['port'] . '/movie/' . $rRow['username'] . '/' . $rRow['password'] . '/' . $rRow['stream_id'] . '.' . $rRow['channel_id'];
- $rButtons = "
";
- }
- if (0 < strlen($rRow['stream_icon']) && $rRow['type'] == 'live') {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rProviderData = json_decode($rRow['data'], true);
- $rExpires = ($rProviderData['exp_date'] ?: 'Never');
- $rMaxConnections = ($rProviderData['max_connections'] ?: '∞');
- $rProvider = "
Connections: ' . $rProviderData['active_connections'] . ' / ' . $rMaxConnections . "'>" . $rRow['name'] . '';
- if ($rRow['type'] == 'live') {
- $rReturn['data'][] = array($rIcon, $rRow['stream_display_name'], $rProvider, $rButtons);
- } else {
- $rReturn['data'][] = array($rRow['stream_display_name'], $rProvider, $rButtons);
- }
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
-}
-if ($rType == 'parent_servers') {
- if (Authorization::check('adv', 'servers')) {
- $rServers = ServerRepository::getAll();
- if (isset($rServers[RequestManager::getAll()['proxy_id']]) && count($rServers[RequestManager::getAll()['proxy_id']]['parent_id']) != 0) {
- $rOrder = array('`id`', '`server_name`', '`server_ip`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`server_type` = 0';
- $rWhere[] = '`id` IN (' . implode(',', array_map('intval', $rServers[RequestManager::getAll()['proxy_id']]['parent_id'])) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`server_name` LIKE ? OR `server_ip` LIKE ?)';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `servers` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `id`, `server_name`, `server_ip` FROM `servers` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rReturn['data'][] = array("
" . $rRow['id'] . '', "
" . $rRow['server_name'] . '', $rRow['server_ip']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'failures_modal') {
- if (Authorization::check('adv', 'streams')) {
- $rLimit = 10;
- $rOrderBy = 'ORDER BY `date` DESC';
- $rWhere = $rWhereV = array();
- $rWhere[] = '`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- if (!(isset(RequestManager::getAll()['server_id']) && 0 < intval(RequestManager::getAll()['server_id'] ?? 0))) {
- } else {
- $rWhere[] = '`server_id` = ?';
- $rWhereV[] = RequestManager::getAll()['server_id'];
- }
- $rWhere[] = '`date` >= UNIX_TIMESTAMP()-' . intval(($rSettings['fails_per_time'] ?: 86400));
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_logs` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `server_id`, `action`, `source`, `date` FROM `streams_logs` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rStreamSource = '';
- if (empty($rRow['source'])) {
- } else {
- $rStreamSource = strtolower(parse_url($rRow['source'])['host']);
- }
- $rReturn['data'][] = array("
" . ServerRepository::getAll()[$rRow['server_id']]['server_name'] . '', $rStreamSource, $rFailureStatusArray[$rRow['action']], date(SettingsManager::getAll()['datetime_format'], $rRow['date']));
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-if ($rType == 'epg_modal') {
- $rLimit = 10;
- $rEPG = EpgService::getStreamEpg(RequestManager::getAll()['stream_id'], time(), time() + 604800);
- if (!($rEPG && $rLimit < count($rEPG))) {
- } else {
- $rEPG = array_slice($rEPG, 0, $rLimit);
- }
- $rReturn['recordsTotal'] = (count($rEPG) ?: 0);
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- foreach ($rEPG as $rRow) {
- if (!$rIsAPI) {
- $rReturn['data'][] = array(date('H:i:s', $rRow['start']), $rRow['title'], $rRow['description']);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- echo json_encode($rReturn);
- exit();
-}
-if ($rType == 'stream_logs') {
- $rOrder = array('`date`', '`action`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream_id'];
- $rWhere[] = '`date` >= (UNIX_TIMESTAMP()-86400)';
- $rOrderBy = 'ORDER BY `date` DESC';
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams_logs` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `date`, `action` FROM `streams_logs` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- $rReturn['data'][] = array(date('H:i:s', $rRow['date']), $rStreamLogsArray[$rRow['action']]);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
-}
-if ($rType == 'ondemand') {
- if (Authorization::check('adv', 'streams')) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`streams`.`id`', '`streams`.`stream_icon`', '`streams`.`stream_display_name`', '`streams_servers`.`server_id`', '`ondemand_check`.`status`', '`ondemand_check`.`response`', '`ondemand_check`.`resolution`', '`ondemand_check`.`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`streams`.`type` = 1';
- $rWhere[] = '`streams`.`direct_source` = 0';
- $rWhere[] = '`streams_servers`.`on_demand` = 1';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 6) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `streams`.`stream_display_name` LIKE ? OR `ondemand_check`.`fps` LIKE ? OR `ondemand_check`.`resolution` LIKE ? OR `ondemand_check`.`video_codec` LIKE ? OR `ondemand_check`.`audio_codec` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'] ?? '')) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (0 >= strlen(RequestManager::getAll()['filter'] ?? '')) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '`ondemand_check`.`status` = 1';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`ondemand_check`.`status` = 0';
- } else {
- if (RequestManager::getAll()['filter'] != 3) {
- } else {
- $rWhere[] = '`ondemand_check`.`status` IS NULL';
- }
- }
- }
- }
- if (0 >= intval(RequestManager::getAll()['server'] ?? 0)) {
- } else {
- $rWhere[] = '`streams_servers`.`server_id` = ?';
- $rWhereV[] = intval(RequestManager::getAll()['server'] ?? 0);
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `ondemand_check` ON `ondemand_check`.`id` = `streams_servers`.`ondemand_check` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `ondemand_check`.`status` AS `ondemand_status`, `ondemand_check`.`date` AS `ondemand_date`, `ondemand_check`.`errors`, `ondemand_check`.`response`, `ondemand_check`.`resolution`, `ondemand_check`.`fps`, `ondemand_check`.`video_codec`, `ondemand_check`.`audio_codec`, `streams`.`id`, `streams`.`type`, `streams`.`stream_icon`, `streams`.`stream_source`, `streams`.`stream_display_name`, `streams_servers`.`server_id`, `streams`.`llod`, `streams`.`category_id`, (SELECT `server_name` FROM `servers` WHERE `id` = `streams_servers`.`server_id`) AS `server_name` FROM `streams` LEFT JOIN `streams_servers` ON `streams_servers`.`stream_id` = `streams`.`id` LEFT JOIN `ondemand_check` ON `ondemand_check`.`id` = `streams_servers`.`ondemand_check` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rUpChecks = $rDownChecks = $rStreamIDs = array();
- foreach ($rRows as $rRow) {
- $rStreamIDs[] = intval($rRow['id']);
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, `server_id`, COUNT(*) AS `count` FROM `ondemand_check` WHERE `stream_id` IN (' . implode(',', $rStreamIDs) . ") AND `status` = 1 GROUP BY CONCAT(`stream_id`, '_', `server_id`);");
- foreach ($db->get_rows() as $rRow) {
- $rUpChecks[intval($rRow['server_id'])][$rRow['stream_id']] = $rRow['count'];
- }
- $db->query('SELECT `stream_id`, `server_id`, COUNT(*) AS `count` FROM `ondemand_check` WHERE `stream_id` IN (' . implode(',', $rStreamIDs) . ") AND `status` = 0 GROUP BY CONCAT(`stream_id`, '_', `server_id`);");
- foreach ($db->get_rows() as $rRow) {
- $rDownChecks[intval($rRow['server_id'])][$rRow['stream_id']] = $rRow['count'];
- }
- }
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- $rServerID = intval($rRow['server_id']);
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'] ?? '')) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'] ?? 0)]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- $rStreamName = "
" . $rRow['stream_display_name'] . "
" . $rCategory . '';
- if ($rRow['server_name']) {
- if (Authorization::check('adv', 'servers')) {
- $rServerName = "
" . $rRow['server_name'] . '';
- } else {
- $rServerName = $rRow['server_name'];
- }
- } else {
- $rServerName = 'No Server Selected';
- }
- if (!empty($rRow['stream_icon'])) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- if (is_null($rRow['ondemand_status'])) {
- $rStatus = '
';
- } else {
- if ($rRow['ondemand_status'] == 1) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- }
- $rChecks = '
';
- $rLastCheck = 'Never';
- $rTimeTaken = "
";
- $rStreamInfoText = "
";
- if (is_null($rRow['ondemand_status'])) {
- } else {
- if (0 >= $rRow['ondemand_date']) {
- } else {
- $rLastCheck = date($rSettings['date_format'], $rRow['ondemand_date']) . '
' . date('H:i:s', $rRow['ondemand_date']);
- }
- if (0 >= $rRow['response']) {
- } else {
- $rTimeTaken = "
';
- }
- if (!($rRow['fps'] || $rRow['video_codec'] || $rRow['audio_codec'] || $rRow['resolution'])) {
- } else {
- $rStreamInfoText = "
" . "\r\n" . ' ' . "\r\n" . ' ' . "\r\n" . " | " . "\r\n" . " | " . "\r\n" . " | " . "\r\n" . " | " . "\r\n" . '
' . "\r\n" . ' ' . "\r\n" . ' | ' . (($rRow['resolution'] ? $rRow['resolution'] . 'p' : 'N/A')) . ' | ' . "\r\n" . ' ' . ((str_replace('mpeg2video', 'mpeg2', $rRow['video_codec']) ?: 'N/A')) . ' | ' . "\r\n" . ' ' . (($rRow['audio_codec'] ?: 'N/A')) . ' | ' . "\r\n" . ' ' . (($rRow['fps'] . ' FPS' ?: 'N/A')) . ' | ' . "\r\n" . '
' . "\r\n" . ' ' . "\r\n" . '
';
- }
- }
- $rReturn['data'][] = array("
" . $rRow['id'] . '', $rIcon, $rStreamName, $rServerName, $rStatus . ' ' . $rChecks, $rTimeTaken, $rStreamInfoText, $rLastCheck);
- } else {
- unset($rRow['stream_source']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'] ?? '', RequestManager::getAll()['hide_columns'] ?? '');
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
-}
-
-function filterRow($rRow, $rShow, $rHide) {
- if ($rShow || $rHide) {
- $rReturn = array();
- foreach (array_keys($rRow) as $rKey) {
- if ($rShow) {
- if (in_array($rKey, $rShow)) {
- $rReturn[$rKey] = $rRow[$rKey];
- }
- } else {
- if ($rHide) {
- if (!in_array($rKey, $rHide)) {
- $rReturn[$rKey] = $rRow[$rKey];
- }
- }
- }
- }
- return $rReturn;
- } else {
- return $rRow;
- }
-}
diff --git a/src/includes/api/reseller/table.php b/src/includes/api/reseller/table.php
deleted file mode 100644
index 0058e1ea..00000000
--- a/src/includes/api/reseller/table.php
+++ /dev/null
@@ -1,1849 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-session_start();
-session_write_close();
-if (file_exists('../www/init.php')) {
- require_once '../www/init.php';
-} else {
- require_once '../../../www/init.php';
-}
-if (PHP_ERRORS) {
-} else {
- if (!(empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
- } else {
- exit();
- }
-}
-$rReturn = array('draw' => intval(RequestManager::getAll()['draw']), 'recordsTotal' => 0, 'recordsFiltered' => 0, 'data' => array());
-$rIsAPI = false;
-if (isset(RequestManager::getAll()['api_key'])) {
- $rReturn = array('status' => 'STATUS_SUCCESS', 'data' => array());
- $db->query('SELECT `id` FROM `users` LEFT JOIN `users_groups` ON `users_groups`.`group_id` = `users`.`member_group_id` WHERE `api_key` = ? AND LENGTH(`api_key`) > 0 AND `is_reseller` = 1 AND `status` = 1;', RequestManager::getAll()['api_key']);
- if ($db->num_rows() != 0) {
- $rUserID = $db->get_row()['id'];
- $rIsAPI = true;
- require_once MAIN_HOME . 'includes/admin.php';
- $rUserInfo = UserRepository::getRegisteredUserById($rUserID);
- $rPermissions = array_merge(getPermissions($rUserInfo['member_group_id']), getGroupPermissions($rUserInfo['id']));
- if (0 >= strlen($rUserInfo['timezone'])) {
- } else {
- date_default_timezone_set($rUserInfo['timezone']);
- }
- } else {
- echo json_encode(array('status' => 'STATUS_FAILURE', 'error' => 'Invalid API key.'));
- exit();
- }
-} else {
- if (isset($_SESSION['reseller'])) {
- include 'functions.php';
- } else {
- echo json_encode($rReturn);
- exit();
- }
-}
-if (!$rUserInfo['id']) {
- echo json_encode($rReturn);
- exit();
-}
-if (isset($rUserInfo['reports'])) {
- $rType = RequestManager::getAll()['id'];
- $rStart = intval(RequestManager::getAll()['start']);
- $rLimit = intval(RequestManager::getAll()['length']);
- if (!(1000 < $rLimit || $rLimit <= 0)) {
- } else {
- $rLimit = 1000;
- }
- if ($rType == 'lines') {
- if ($rPermissions['create_line']) {
- $rOrder = array('`lines`.`id`', '`lines`.`username`', '`lines`.`password`', '`users`.`username`', '`lines`.`enabled` - `lines`.`admin_enabled`', '`active_connections` > 0', '`lines`.`is_trial`', '`active_connections`', '`lines`.`max_connections`', '`lines`.`exp_date`', '`last_activity`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`lines`.`is_mag` = 0 AND `lines`.`is_e2` = 0';
- $rWhere[] = '`lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 6) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines`.`username` LIKE ? OR `lines`.`password` LIKE ? OR `users`.`username` LIKE ? OR FROM_UNIXTIME(`exp_date`) LIKE ? OR `lines`.`max_connections` LIKE ? OR `lines`.`reseller_notes` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'])) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`lines`.`admin_enabled` = 1 AND `lines`.`enabled` = 1 AND (`lines`.`exp_date` IS NULL OR `lines`.`exp_date` > UNIX_TIMESTAMP()))';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`lines`.`enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '`lines`.`admin_enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 4) {
- $rWhere[] = '(`lines`.`exp_date` IS NOT NULL AND `lines`.`exp_date` <= UNIX_TIMESTAMP())';
- } else {
- if (RequestManager::getAll()['filter'] != 5) {
- } else {
- $rWhere[] = '`lines`.`is_trial` = 1';
- }
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'])) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(`lines`.`id`) AS `count` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` ' . $rWhereString . ';';
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines`.`id`, `lines`.`member_id`, `lines`.`last_activity`, `lines`.`last_activity_array`, `lines`.`username`, `lines`.`password`, `lines`.`exp_date`, `lines`.`admin_enabled`, `lines`.`is_restreamer`, `lines`.`enabled`, `lines`.`admin_notes`, `lines`.`reseller_notes`, `lines`.`max_connections`, `lines`.`is_trial`, (SELECT COUNT(*) AS `active_connections` FROM `lines_live` WHERE `user_id` = `lines`.`id` AND `hls_end` = 0) AS `active_connections` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rActivityIDs = $rLineInfo = $rLineIDs = array();
- foreach ($rRows as $rRow) {
- $rLineIDs[] = intval($rRow['id']);
- $rLineInfo[intval($rRow['id'])] = array('owner_name' => null, 'stream_display_name' => null, 'stream_id' => null, 'last_active' => null);
- if ($rLastInfo = json_decode($rRow['last_activity_array'], true)) {
- $rLineInfo[intval($rRow['id'])]['stream_id'] = $rLastInfo['stream_id'];
- $rLineInfo[intval($rRow['id'])]['last_active'] = $rLastInfo['date_end'];
- } else {
- if (!$rRow['last_activity']) {
- } else {
- $rActivityIDs[] = intval($rRow['last_activity']);
- }
- }
- }
- if (0 >= count($rLineIDs)) {
- } else {
- $db->query('SELECT `users`.`username`, `lines`.`id` FROM `users` LEFT JOIN `lines` ON `lines`.`member_id` = `users`.`id` WHERE `lines`.`id` IN (' . implode(',', $rLineIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rLineInfo[$rRow['id']]['owner_name'] = $rRow['username'];
- }
- if (SettingsManager::getAll()['redis_handler']) {
- $rConnectionCount = array();
- $rConnectionMap = ConnectionTracker::getUserConnections($rLineIDs, false);
- $rStreamIDs = array();
- foreach ($rConnectionMap as $rUserID => $rConnections) {
- foreach ($rConnections as $rConnection) {
- if (in_array($rConnection['stream_id'], $rStreamIDs)) {
- } else {
- $rStreamIDs[] = intval($rConnection['stream_id']);
- }
- }
- }
- $rStreamMap = array();
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `id`, `stream_display_name` FROM `streams` WHERE `id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rStreamMap[$rRow['id']] = $rRow['stream_display_name'];
- }
- }
- foreach (array_keys($rConnectionMap) as $rUserID) {
- array_multisort(array_column($rConnectionMap[$rUserID], 'date_start'), SORT_DESC, $rConnectionMap[$rUserID]);
- $rLineInfo[$rUserID]['stream_display_name'] = $rStreamMap[$rConnectionMap[$rUserID][0]['stream_id']];
- $rLineInfo[$rUserID]['stream_id'] = $rConnectionMap[$rUserID][0]['stream_id'];
- $rLineInfo[$rUserID]['last_active'] = $rConnectionMap[$rUserID][0]['date_start'];
- $rConnectionCount[$rUserID] = count($rConnectionMap[$rUserID]);
- }
- unset($rConnectionMap);
- } else {
- $db->query('SELECT `lines_live`.`user_id`, `lines_live`.`stream_id`, `lines_live`.`date_start` AS `last_active`, `streams`.`stream_display_name` FROM `lines_live` LEFT JOIN `streams` ON `streams`.`id` = `lines_live`.`stream_id` INNER JOIN (SELECT `user_id`, MAX(`date_start`) AS `ts` FROM `lines_live` GROUP BY `user_id`) `maxt` ON (`lines_live`.`user_id` = `maxt`.`user_id` AND `lines_live`.`date_start` = `maxt`.`ts`) WHERE `lines_live`.`user_id` IN (' . implode(',', $rLineIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rLineInfo[$rRow['user_id']]['stream_display_name'] = $rRow['stream_display_name'];
- $rLineInfo[$rRow['user_id']]['stream_id'] = $rRow['stream_id'];
- $rLineInfo[$rRow['user_id']]['last_active'] = $rRow['last_active'];
- }
- }
- }
- if (0 >= count($rActivityIDs)) {
- } else {
- $db->query('SELECT `user_id`, `stream_id`, `date_end` AS `last_active` FROM `lines_activity` WHERE `activity_id` IN (' . implode(',', $rActivityIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- if (isset($rLineInfo[$rRow['user_id']]['stream_id'])) {
- } else {
- $rLineInfo[$rRow['user_id']]['stream_id'] = $rRow['stream_id'];
- $rLineInfo[$rRow['user_id']]['last_active'] = $rRow['last_active'];
- }
- }
- }
- foreach ($rRows as $rRow) {
- $rRow = array_merge($rRow, $rLineInfo[$rRow['id']]);
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['active_connections'] = (isset($rConnectionCount[$rRow['id']]) ? $rConnectionCount[$rRow['id']] : 0);
- }
- if (!$rIsAPI) {
- if (!$rRow['admin_enabled']) {
- $rStatus = '
';
- } else {
- if (!$rRow['enabled']) {
- $rStatus = '
';
- } else {
- if ($rRow['exp_date'] && $rRow['exp_date'] < time()) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- }
- }
- if (0 < $rRow['active_connections']) {
- $rActive = '
';
- } else {
- $rActive = '
';
- }
- if ($rRow['is_trial']) {
- $rTrial = '
';
- } else {
- $rTrial = '
';
- }
- if ($rRow['exp_date']) {
- if ($rRow['exp_date'] < time()) {
- $rExpDate = '
' . date($rSettings['date_format'], $rRow['exp_date']) . '
' . date('H:i:s', $rRow['exp_date']) . '';
- } else {
- $rExpDate = date($rSettings['date_format'], $rRow['exp_date']) . "
" . date('H:i:s', $rRow['exp_date']) . '';
- }
- } else {
- $rExpDate = '∞';
- }
- if (0 < $rRow['active_connections']) {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rActiveConnections = "
';
- } else {
- $rActiveConnections = "
';
- }
- } else {
- $rActiveConnections = "
";
- }
- if ($rRow['max_connections'] == 0) {
- $rMaxConnections = "
";
- } else {
- $rMaxConnections = "
';
- }
- $rButtons = '
';
- $rNotes = '';
- if (0 >= strlen($rRow['reseller_notes'])) {
- } else {
- if (strlen($rNotes) == 0) {
- } else {
- $rNotes .= "\n";
- }
- $rNotes .= $rRow['reseller_notes'];
- }
- if (0 < strlen($rNotes)) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- if (!$rPermissions['allow_download']) {
- } else {
- $rButtons .= "
";
- }
- if (!$rPermissions['reseller_client_connection_logs']) {
- } else {
- if (0 < $rRow['active_connections']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
';
- }
- }
- if (!$rRow['is_isplock']) {
- } else {
- $rButtons .= '
";
- }
- if ($rRow['enabled']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
";
- $rButtons .= '
';
- if ($rRow['active_connections'] && $rRow['last_active']) {
- $rLastActive = "
" . $rRow['stream_display_name'] . "Online: " . TimeUtils::secondsToTime(time() - $rRow['last_active']) . '';
- } else {
- if ($rRow['last_active']) {
- $rLastActive = date($rSettings['date_format'], $rRow['last_active']) . "
" . date('H:i:s', $rRow['last_active']) . '';
- } else {
- $rLastActive = 'Never';
- }
- }
- if (in_array($rRow['member_id'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rOwner = "
" . $rRow['owner_name'] . '';
- } else {
- $rOwner = "
" . $rRow['owner_name'] . "
(indirect)";
- }
- $rReturn['data'][] = array("
" . $rRow['id'] . '', "
" . $rRow['username'] . '', $rRow['password'], $rOwner, $rStatus, $rActive, $rTrial, $rActiveConnections, $rMaxConnections, $rExpDate, $rLastActive, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'mags') {
- if ($rPermissions['create_mag']) {
- $rOrder = array('`lines`.`id`', '`lines`.`username`', '`mag_devices`.`mac`', '`mag_devices`.`stb_type`', '`users`.`username`', '`lines`.`enabled`', '`active_connections`', '`lines`.`is_trial`', '`lines`.`exp_date`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 6) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines`.`username` LIKE ? OR `mag_devices`.`mac` LIKE ? OR `mag_devices`.`stb_type` LIKE ? OR `users`.`username` LIKE ? OR FROM_UNIXTIME(`exp_date`) LIKE ? OR `lines`.`reseller_notes` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'])) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`lines`.`admin_enabled` = 1 AND `lines`.`enabled` = 1 AND (`lines`.`exp_date` IS NULL OR `lines`.`exp_date` > UNIX_TIMESTAMP()))';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`lines`.`enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`lines`.`exp_date` IS NOT NULL AND `lines`.`exp_date` <= UNIX_TIMESTAMP())';
- } else {
- if (RequestManager::getAll()['filter'] != 4) {
- } else {
- $rWhere[] = '`lines`.`is_trial` = 1';
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'])) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(`lines`.`id`) AS `count` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` INNER JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines`.`id`, `lines`.`username`, `lines`.`member_id`, `lines`.`is_isplock`, `mag_devices`.`mac`, `mag_devices`.`stb_type`, `mag_devices`.`mag_id`, `lines`.`exp_date`, `lines`.`admin_enabled`, `lines`.`enabled`, `lines`.`reseller_notes`, `lines`.`max_connections`, `lines`.`is_trial`, `users`.`username` AS `owner_name`, (SELECT count(*) FROM `lines_live` WHERE `lines`.`id` = `lines_live`.`user_id` AND `hls_end` = 0) AS `active_connections` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` INNER JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rLineIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['id']) {
- } else {
- $rLineIDs[] = intval($rRow['id']);
- }
- }
- if (0 >= count($rLineIDs)) {
- } else {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = array();
- $rConnectionMap = ConnectionTracker::getUserConnections($rLineIDs, false);
- foreach (array_keys($rConnectionMap) as $rUserID) {
- $rConnectionCount[$rUserID] = count($rConnectionMap[$rUserID]);
- }
- unset($rConnectionMap);
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['active_connections'] = (isset($rConnectionCount[$rRow['id']]) ? $rConnectionCount[$rRow['id']] : 0);
- }
- if (!$rIsAPI) {
- if (!$rRow['admin_enabled']) {
- $rStatus = '
';
- } else {
- if (!$rRow['enabled']) {
- $rStatus = '
';
- } else {
- if ($rRow['exp_date'] && $rRow['exp_date'] < time()) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- }
- }
- if (0 < $rRow['active_connections']) {
- $rActive = '
';
- } else {
- $rActive = '
';
- }
- if ($rRow['is_trial']) {
- $rTrial = '
';
- } else {
- $rTrial = '
';
- }
- if ($rRow['exp_date']) {
- if ($rRow['exp_date'] < time()) {
- $rExpDate = '
' . date($rSettings['date_format'], $rRow['exp_date']) . '
' . date('H:i:s', $rRow['exp_date']) . '';
- } else {
- $rExpDate = date($rSettings['date_format'], $rRow['exp_date']) . "
" . date('H:i:s', $rRow['exp_date']) . '';
- }
- } else {
- $rExpDate = '∞';
- }
- $rButtons = '
';
- $rNotes = '';
- if (0 >= strlen($rRow['reseller_notes'])) {
- } else {
- if (strlen($rNotes) == 0) {
- } else {
- $rNotes .= "\n";
- }
- $rNotes .= $rRow['reseller_notes'];
- }
- if (0 < strlen($rNotes)) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
";
- $rButtons .= '
';
- if (!$rRow['is_isplock']) {
- } else {
- $rButtons .= '
";
- }
- if (!$rPermissions['create_line']) {
- } else {
- $rButtons .= '
";
- }
- if (!$rPermissions['reseller_client_connection_logs']) {
- } else {
- if (0 < $rRow['active_connections']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
';
- }
- }
- if ($rRow['enabled'] == 1) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
";
- $rButtons .= '
';
- if (in_array($rRow['member_id'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rOwner = "
" . $rRow['owner_name'] . '';
- } else {
- $rOwner = "
" . $rRow['owner_name'] . "
(indirect)";
- }
- $rReturn['data'][] = array("
" . $rRow['mag_id'] . '', $rRow['username'], "
" . $rRow['mac'] . '', $rRow['stb_type'], $rOwner, $rStatus, $rActive, $rTrial, $rExpDate, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'enigmas') {
- if ($rPermissions['create_enigma']) {
- $rOrder = array('`lines`.`id`', '`lines`.`username`', '`enigma2_devices`.`mac`', '`enigma2_devices`.`public_ip`', '`users`.`username`', '`lines`.`enabled`', '`active_connections`', '`lines`.`is_trial`', '`lines`.`exp_date`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 6) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines`.`username` LIKE ? OR `enigma2_devices`.`mac` LIKE ? OR `enigma2_devices`.`public_ip` LIKE ? OR `users`.`username` LIKE ? OR FROM_UNIXTIME(`exp_date`) LIKE ? OR `lines`.`reseller_notes` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'])) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '(`lines`.`admin_enabled` = 1 AND `lines`.`enabled` = 1 AND (`lines`.`exp_date` IS NULL OR `lines`.`exp_date` > UNIX_TIMESTAMP()))';
- } else {
- if (RequestManager::getAll()['filter'] == 2) {
- $rWhere[] = '`lines`.`enabled` = 0';
- } else {
- if (RequestManager::getAll()['filter'] == 3) {
- $rWhere[] = '(`lines`.`exp_date` IS NOT NULL AND `lines`.`exp_date` <= UNIX_TIMESTAMP())';
- } else {
- if (RequestManager::getAll()['filter'] != 4) {
- } else {
- $rWhere[] = '`lines`.`is_trial` = 1';
- }
- }
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'])) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(`lines`.`id`) AS `count` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` INNER JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `lines`.`id`, `lines`.`username`, `lines`.`member_id`, `lines`.`is_isplock`, `enigma2_devices`.`mac`, `enigma2_devices`.`public_ip`, `enigma2_devices`.`device_id`, `lines`.`exp_date`, `lines`.`admin_enabled`, `lines`.`enabled`, `lines`.`reseller_notes`, `lines`.`max_connections`, `lines`.`is_trial`, `users`.`username` AS `owner_name`, (SELECT count(*) FROM `lines_live` WHERE `lines`.`id` = `lines_live`.`user_id` AND `hls_end` = 0) AS `active_connections` FROM `lines` LEFT JOIN `users` ON `users`.`id` = `lines`.`member_id` INNER JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- $rLineIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['id']) {
- } else {
- $rLineIDs[] = intval($rRow['id']);
- }
- }
- if (0 >= count($rLineIDs)) {
- } else {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = array();
- $rConnectionMap = ConnectionTracker::getUserConnections($rLineIDs, false);
- foreach (array_keys($rConnectionMap) as $rUserID) {
- $rConnectionCount[$rUserID] = count($rConnectionMap[$rUserID]);
- }
- unset($rConnectionMap);
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['active_connections'] = (isset($rConnectionCount[$rRow['id']]) ? $rConnectionCount[$rRow['id']] : 0);
- }
- if (!$rIsAPI) {
- if (!$rRow['admin_enabled']) {
- $rStatus = '
';
- } else {
- if (!$rRow['enabled']) {
- $rStatus = '
';
- } else {
- if ($rRow['exp_date'] && $rRow['exp_date'] < time()) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- }
- }
- if (0 < $rRow['active_connections']) {
- $rActive = '
';
- } else {
- $rActive = '
';
- }
- if ($rRow['is_trial']) {
- $rTrial = '
';
- } else {
- $rTrial = '
';
- }
- if ($rRow['exp_date']) {
- if ($rRow['exp_date'] < time()) {
- $rExpDate = '
' . date($rSettings['date_format'], $rRow['exp_date']) . '
' . date('H:i:s', $rRow['exp_date']) . '';
- } else {
- $rExpDate = date($rSettings['date_format'], $rRow['exp_date']) . "
" . date('H:i:s', $rRow['exp_date']) . '';
- }
- } else {
- $rExpDate = '∞';
- }
- $rButtons = '
';
- $rNotes = '';
- if (0 >= strlen($rRow['reseller_notes'])) {
- } else {
- if (strlen($rNotes) == 0) {
- } else {
- $rNotes .= "\n";
- }
- $rNotes .= $rRow['reseller_notes'];
- }
- if (0 < strlen($rNotes)) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- $rButtons .= '
';
- if (!$rRow['is_isplock']) {
- } else {
- $rButtons .= '
";
- }
- if (!$rPermissions['create_line']) {
- } else {
- $rButtons .= '
";
- }
- if (!$rPermissions['reseller_client_connection_logs']) {
- } else {
- if (0 < $rRow['active_connections']) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
';
- }
- }
- if ($rRow['enabled'] == 1) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
";
- $rButtons .= '
';
- if (in_array($rRow['member_id'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rOwner = "
" . $rRow['owner_name'] . '';
- } else {
- $rOwner = "
" . $rRow['owner_name'] . "
(indirect)";
- }
- $rReturn['data'][] = array("
" . $rRow['device_id'] . '', $rRow['username'], "
" . $rRow['mac'] . '', "
" . $rRow['public_ip'] . '', $rOwner, $rStatus, $rActive, $rTrial, $rExpDate, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'streams') {
- if ($rPermissions['can_view_vod']) {
- $rCategories = CategoryService::getAllByType('live');
- $rOrder = array('`id`', false, '`stream_display_name`', '`category_id`', '`clients`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rCreated = isset(RequestManager::getAll()['created']);
- $rWhere = $rWhereV = array();
- if (0 < count($rPermissions['stream_ids'])) {
- $rWhere[] = '`streams`.`id` IN (' . implode(',', array_map('intval', $rPermissions['stream_ids'])) . ')';
- if ($rCreated) {
- $rWhere[] = '`type` = 3';
- } else {
- $rWhere[] = '`type` = 1';
- }
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`id` LIKE ? OR `stream_display_name` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'])) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(`streams`.`id`) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `id`, `stream_icon`, `stream_display_name`, `tv_archive_duration`, `tv_archive_server_id`, `category_id`, (SELECT COUNT(*) FROM `lines_live` LEFT JOIN `lines` ON `lines`.`id` = `lines_live`.`user_id` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0 AND `lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')) AS `clients` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = $rReports = array();
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserInfo['reports']) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rReports[] = $rRow['id'];
- }
- if (0 >= count($rReports)) {
- } else {
- foreach (ConnectionTracker::getUserConnections($rReports, false) as $rUserID => $rConnections) {
- foreach ($rConnections as $rConnection) {
- $rConnectionCount[$rConnection['stream_id']]++;
- }
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (!(0 < $rRow['tv_archive_duration'] && 0 < $rRow['tv_archive_server_id'])) {
- } else {
- $rRow['stream_display_name'] .= "
";
- }
- if (0 < $rRow['clients']) {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rButtons = '
";
- $rClients = "
';
- } else {
- $rButtons = '
';
- $rClients = "
';
- }
- } else {
- $rButtons = '
';
- $rClients = "
";
- }
- if (0 < strlen($rRow['stream_icon'])) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rIcon, $rRow['stream_display_name'], $rCategory, $rClients, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'radios') {
- if ($rPermissions['can_view_vod']) {
- $rCategories = CategoryService::getAllByType('radio');
- $rOrder = array('`id`', false, '`stream_display_name`', '`category_id`', '`clients`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rCreated = isset(RequestManager::getAll()['created']);
- $rWhere = $rWhereV = array();
- if (0 < count($rPermissions['stream_ids'])) {
- $rWhere[] = '`streams`.`id` IN (' . implode(',', array_map('intval', $rPermissions['stream_ids'])) . ')';
- $rWhere[] = '`type` = 4';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`id` LIKE ? OR `stream_display_name` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'])) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(`streams`.`id`) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `id`, `stream_icon`, `stream_display_name`, `category_id`, (SELECT COUNT(*) FROM `lines_live` LEFT JOIN `lines` ON `lines`.`id` = `lines_live`.`user_id` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0 AND `lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')) AS `clients` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = $rReports = array();
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserInfo['reports']) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rReports[] = $rRow['id'];
- }
- if (0 >= count($rReports)) {
- } else {
- foreach (ConnectionTracker::getUserConnections($rReports, false) as $rUserID => $rConnections) {
- foreach ($rConnections as $rConnection) {
- $rConnectionCount[$rConnection['stream_id']]++;
- }
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (0 < $rRow['clients']) {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rButtons = '
";
- $rClients = "
';
- } else {
- $rButtons = '
';
- $rClients = "
';
- }
- } else {
- $rButtons = '
';
- $rClients = "
";
- }
- if (0 < strlen($rRow['stream_icon'])) {
- $rIcon = "

";
- } else {
- $rIcon = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rIcon, $rRow['stream_display_name'], $rCategory, $rClients, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'movies') {
- if ($rPermissions['can_view_vod']) {
- $rCategories = CategoryService::getAllByType('movie');
- $rOrder = array('`id`', false, '`stream_display_name`', '`category_id`', '`clients`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rCreated = isset(RequestManager::getAll()['created']);
- $rWhere = $rWhereV = array();
- if (0 < count($rPermissions['stream_ids'])) {
- $rWhere[] = '`streams`.`id` IN (' . implode(',', array_map('intval', $rPermissions['stream_ids'])) . ')';
- $rWhere[] = '`type` = 2';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 2) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`id` LIKE ? OR `stream_display_name` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'])) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(`streams`.`id`) AS `count` FROM `streams` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `id`, `stream_icon`, `stream_display_name`, `movie_properties`, `category_id`, (SELECT COUNT(*) FROM `lines_live` LEFT JOIN `lines` ON `lines`.`id` = `lines_live`.`user_id` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0 AND `lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')) AS `clients` FROM `streams` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = $rReports = array();
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserInfo['reports']) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rReports[] = $rRow['id'];
- }
- if (0 >= count($rReports)) {
- } else {
- foreach (ConnectionTracker::getUserConnections($rReports, false) as $rUserID => $rConnections) {
- foreach ($rConnections as $rConnection) {
- $rConnectionCount[$rConnection['stream_id']]++;
- }
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- }
- if (!$rIsAPI) {
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (0 < $rRow['clients']) {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rButtons = '
";
- $rClients = "
';
- } else {
- $rButtons = '
';
- $rClients = "
';
- }
- } else {
- $rButtons = '
';
- $rClients = "
";
- }
- $rProperties = json_decode($rRow['movie_properties'], true);
- if (0 < strlen($rProperties['movie_image'])) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rImage, $rRow['stream_display_name'], $rCategory, $rClients, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'episodes') {
- if ($rPermissions['can_view_vod']) {
- $rCategories = CategoryService::getAllByType('series');
- $rOrder = array('`id`', false, '`stream_display_name`', '`category_id`', '`clients`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rCreated = isset(RequestManager::getAll()['created']);
- $rWhere = $rWhereV = array();
- if (0 < count($rPermissions['stream_ids'])) {
- $rWhere[] = '`streams`.`id` IN (' . implode(',', array_map('intval', $rPermissions['stream_ids'])) . ')';
- $rWhere[] = '`type` = 5';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`streams`.`id` LIKE ? OR `stream_display_name` LIKE ? OR `streams_series`.`title` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['category'])) {
- } else {
- $rWhere[] = "JSON_CONTAINS(`streams_series`.`category_id`, ?, '\$')";
- $rWhereV[] = RequestManager::getAll()['category'];
- }
- if (0 >= strlen(RequestManager::getAll()['series'])) {
- } else {
- $rWhere[] = '`streams_series`.`id` = ?';
- $rWhereV[] = RequestManager::getAll()['series'];
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- $rCountQuery = 'SELECT COUNT(`streams`.`id`) AS `count` FROM `streams` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `streams`.`id`, `stream_icon`, `stream_display_name`, `movie_properties`, `streams_series`.`category_id`, `streams_series`.`title`, `streams_episodes`.`season_num`, (SELECT COUNT(*) FROM `lines_live` LEFT JOIN `lines` ON `lines`.`id` = `lines_live`.`user_id` WHERE `lines_live`.`stream_id` = `streams`.`id` AND `hls_end` = 0 AND `lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')) AS `clients` FROM `streams` LEFT JOIN `streams_episodes` ON `streams_episodes`.`stream_id` = `streams`.`id` LEFT JOIN `streams_series` ON `streams_series`.`id` = `streams_episodes`.`series_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rConnectionCount = $rReports = array();
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserInfo['reports']) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rReports[] = $rRow['id'];
- }
- if (0 >= count($rReports)) {
- } else {
- foreach (ConnectionTracker::getUserConnections($rReports, false) as $rUserID => $rConnections) {
- foreach ($rConnections as $rConnection) {
- $rConnectionCount[$rConnection['stream_id']]++;
- }
- }
- }
- }
- foreach ($rRows as $rRow) {
- if (!SettingsManager::getAll()['redis_handler']) {
- } else {
- $rRow['clients'] = ($rConnectionCount[$rRow['id']] ?: 0);
- }
- if (!$rIsAPI) {
- $rSeriesName = $rRow['title'] . ' - Season ' . $rRow['season_num'];
- $rStreamName = '
' . $rRow['stream_display_name'] . "" . $rSeriesName . '';
- $rCategoryIDs = json_decode($rRow['category_id'], true);
- if (0 < strlen(RequestManager::getAll()['category'])) {
- $rCategory = ($rCategories[intval(RequestManager::getAll()['category'])]['category_name'] ?: 'No Category');
- } else {
- $rCategory = ($rCategories[$rCategoryIDs[0]]['category_name'] ?: 'No Category');
- }
- if (1 >= count($rCategoryIDs)) {
- } else {
- $rCategory .= ' (+' . (count($rCategoryIDs) - 1) . ' others)';
- }
- if (0 < $rRow['clients']) {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rButtons = '
";
- $rClients = "
';
- } else {
- $rButtons = '
';
- $rClients = "
';
- }
- } else {
- $rButtons = '
';
- $rClients = "
";
- }
- $rProperties = json_decode($rRow['movie_properties'], true);
- if (0 < strlen($rProperties['movie_image'])) {
- $rImage = "

";
- } else {
- $rImage = '';
- }
- $rReturn['data'][] = array($rRow['id'], $rImage, $rStreamName, $rCategory, $rClients, $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'line_activity') {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rOrder = array('`username`', '`streams`.`stream_display_name`', '`lines_activity`.`user_agent`', '`lines_activity`.`isp`', '`lines_activity`.`user_ip`', '`lines_activity`.`date_start`', '`lines_activity`.`date_end`', '`lines_activity`.`date_end` - `lines_activity`.`date_start`', '`lines_activity`.`container`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 10) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines_activity`.`user_agent` LIKE ? OR `lines_activity`.`user_ip` LIKE ? OR `lines_activity`.`container` LIKE ? OR FROM_UNIXTIME(`lines_activity`.`date_start`) LIKE ? OR FROM_UNIXTIME(`lines_activity`.`date_end`) LIKE ? OR `lines_activity`.`geoip_country_code` LIKE ? OR `lines`.`username` LIKE ? OR `mag_devices`.`mac` LIKE ? OR `enigma2_devices`.`mac` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'])) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range']) - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`lines_activity`.`date_start` >= ? AND `lines_activity`.`date_end` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['stream'])) {
- } else {
- $rWhere[] = '`lines_activity`.`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream'];
- }
- if (0 >= strlen(RequestManager::getAll()['user'])) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['user'];
- }
- if (0 >= strlen(RequestManager::getAll()['line'])) {
- } else {
- $rWhere[] = '`lines_activity`.`user_id` = ?';
- $rWhereV[] = RequestManager::getAll()['line'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines_activity` LEFT JOIN `lines` ON `lines_activity`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_activity`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_activity`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_activity`.`user_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `mag_devices`.`mag_id`, `enigma2_devices`.`device_id`, `lines`.`is_e2`, `lines`.`is_mag`, `lines_activity`.`activity_id`, `lines_activity`.`container`, `lines_activity`.`isp`, `lines_activity`.`user_id`, `lines_activity`.`stream_id`, `streams`.`series_no`, `lines_activity`.`server_id`, `lines_activity`.`user_agent`, `lines_activity`.`user_ip`, `lines_activity`.`container`, `lines_activity`.`date_start`, `lines_activity`.`date_end`, `lines_activity`.`geoip_country_code`, IF(`lines`.`is_mag`, `mag_devices`.`mac`, IF(`lines`.`is_e2`, `enigma2_devices`.`mac`, `lines`.`username`)) AS `username`, `streams`.`stream_display_name`, `streams`.`type`, `lines`.`is_restreamer` FROM `lines_activity` LEFT JOIN `lines` ON `lines_activity`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_activity`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_activity`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_activity`.`user_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['is_mag']) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- if ($rRow['is_e2']) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = "
" . $rRow['username'] . '';
- }
- }
- $rChannel = $rRow['stream_display_name'];
- if (0 < strlen($rRow['geoip_country_code'])) {
- $rGeoCountry = "

";
- } else {
- $rGeoCountry = '';
- }
- if ($rRow['user_ip']) {
- $rIP = $rGeoCountry . "
" . $rRow['user_ip'] . '';
- } else {
- $rIP = '';
- }
- if ($rRow['date_start']) {
- $rStart = date($rSettings['datetime_format'], $rRow['date_start']);
- } else {
- $rStart = '';
- }
- if ($rRow['date_end']) {
- $rStop = date($rSettings['datetime_format'], $rRow['date_end']);
- } else {
- $rStop = '';
- }
- $rPlayer = trim(explode('(', $rRow['user_agent'])[0]);
- $rDuration = $rRow['date_end'] - $rRow['date_start'];
- $rColour = 'success';
- if (86400 <= $rDuration) {
- $rDuration = sprintf('%02dd %02dh', $rDuration / 86400, ($rDuration / 3600) % 24);
- $rColour = 'danger';
- } else {
- if (3600 <= $rDuration) {
- if (14400 < $rDuration) {
- $rColour = 'warning';
- } else {
- if (43200 >= $rDuration) {
- } else {
- $rColour = 'danger';
- }
- }
- $rDuration = sprintf('%02dh %02dm', $rDuration / 3600, ($rDuration / 60) % 60);
- } else {
- $rDuration = sprintf('%02dm %02ds', ($rDuration / 60) % 60, $rDuration % 60);
- }
- }
- $rDuration = "
';
- $rReturn['data'][] = array($rUsername, $rChannel, $rPlayer, $rRow['isp'], $rIP, $rStart, $rStop, $rDuration, strtoupper($rRow['container']));
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- if ($rType == 'live_connections') {
- if ($rPermissions['reseller_client_connection_logs']) {
- $rRows = array();
- if (SettingsManager::getAll()['redis_handler']) {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? false : true);
- $rReports = array();
- $rUserID = (0 < intval(RequestManager::getAll()['user']) ? intval(RequestManager::getAll()['user']) : null);
- $rStreamID = (0 < intval(RequestManager::getAll()['stream_id']) ? intval(RequestManager::getAll()['stream_id']) : null);
- if ($rUserID && in_array($rUserID, $rUserInfo['reports'])) {
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` = ?;', $rUserID);
- } else {
- $db->query('SELECT `id` FROM `lines` WHERE `member_id` IN (' . implode(',', $rUserInfo['reports']) . ');');
- }
- foreach ($db->get_rows() as $rRow) {
- $rReports[] = $rRow['id'];
- }
- $rKeys = ConnectionTracker::getUserConnections($rReports, false, true);
- if (!$rOrderDirection) {
- } else {
- $rKeys = array_reverse($rKeys);
- }
- $rKeyCount = count($rKeys);
- foreach (RedisManager::instance()->mGet($rKeys) as $rRow) {
- $rRow = igbinary_unserialize($rRow);
- if (is_array($rRow)) {
- if ($rFilterBefore) {
- } else {
- if (!($rStreamID && $rStreamID != $rRow['stream_id'])) {
- if (in_array($rRow['user_id'], $rReports)) {
- } else {
- $rKeyCount--;
- }
- } else {
- $rKeyCount--;
- }
- }
- $rRow['activity_id'] = $rRow['uuid'];
- $rRow['identifier'] = ($rRow['user_id'] ?: $rRow['hmac_id'] . '_' . $rRow['hmac_identifier']);
- $rRow['active_time'] = time() - $rRow['date_start'];
- $rRow['server_name'] = (ServerRepository::getAll()[$rRow['server_id']]['server_name'] ?: '');
- $rRows[] = $rRow;
- } else {
- $rKeyCount--;
- }
- }
- $rOrder = array('uuid', 'divergence', 'identifier', 'stream_display_name', 'user_agent', 'isp', 'user_ip', 'active_time', 'container', null);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- array_multisort(array_column($rRows, $rOrder[$rOrderRow]), ($rOrderDirection ? SORT_ASC : SORT_DESC), $rRows);
- }
- $rRows = array_slice($rRows, $rStart, $rLimit);
- $rUUIDs = $rStreamIDs = $rUserIDs = array();
- foreach ($rRows as $rRow) {
- if (!$rRow['stream_id']) {
- } else {
- $rStreamIDs[] = intval($rRow['stream_id']);
- }
- if (!$rRow['user_id']) {
- } else {
- $rUserIDs[] = intval($rRow['user_id']);
- }
- if (!$rRow['uuid']) {
- } else {
- $rUUIDs[] = $rRow['uuid'];
- }
- }
- $rStreamNames = $rDivergenceMap = $rSeriesMap = $rUserMap = array();
- if (0 >= count($rUserIDs)) {
- } else {
- $db->query('SELECT `lines`.`id`, `lines`.`is_mag`, `lines`.`is_e2`, `lines`.`is_restreamer`, `lines`.`username`, `mag_devices`.`mag_id`, `enigma2_devices`.`device_id` FROM `lines` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines`.`id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines`.`id` WHERE `lines`.`id` IN (' . implode(',', $rUserIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rUserID = $rRow['id'];
- unset($rRow['id']);
- $rUserMap[$rUserID] = $rRow;
- }
- }
- if (0 >= count($rStreamIDs)) {
- } else {
- $db->query('SELECT `stream_id`, `series_id` FROM `streams_episodes` WHERE `stream_id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rSeriesMap[$rRow['stream_id']] = $rRow['series_id'];
- }
- $db->query('SELECT `id`, `type`, `stream_display_name` FROM `streams` WHERE `id` IN (' . implode(',', $rStreamIDs) . ');');
- foreach ($db->get_rows() as $rRow) {
- $rStreamNames[$rRow['id']] = array($rRow['stream_display_name'], $rRow['type']);
- }
- }
- if (0 >= count($rUUIDs)) {
- } else {
- $db->query("SELECT `uuid`, `divergence` FROM `lines_divergence` WHERE `uuid` IN ('" . implode("','", $rUUIDs) . "');");
- foreach ($db->get_rows() as $rRow) {
- $rDivergenceMap[$rRow['uuid']] = $rRow['divergence'];
- }
- }
- $i = 0;
- while ($i < count($rRows)) {
- $rRows[$i]['divergence'] = ($rDivergenceMap[$rRows[$i]['uuid']] ?: 0);
- $rRows[$i]['series_no'] = ($rSeriesMap[$rRows[$i]['stream_id']] ?: null);
- $rRows[$i]['stream_display_name'] = ($rStreamNames[$rRows[$i]['stream_id']][0] ?: '');
- $rRows[$i]['type'] = ($rStreamNames[$rRows[$i]['stream_id']][1] ?: 1);
- $rRows[$i] = array_merge($rRows[$i], ($rUserMap[$rRows[$i]['user_id']] ?: array()));
- $i++;
- }
- $rReturn['recordsTotal'] = $rKeyCount;
- $rReturn['recordsFiltered'] = ($rIsAPI ? ($rReturn['recordsTotal'] < $rLimit ? $rReturn['recordsTotal'] : $rLimit) : $rReturn['recordsTotal']);
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrder = array('`lines_live`.`activity_id`', '`lines_live`.`divergence`', '`username`', '`streams`.`stream_display_name`', '`lines_live`.`user_agent`', '`lines_live`.`isp`', '`lines_live`.`user_ip`', 'UNIX_TIMESTAMP() - `lines_live`.`date_start`', '`lines_live`.`container`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`hls_end` = 0';
- $rWhere[] = '`lines`.`member_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 9) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`lines_live`.`user_agent` LIKE ? OR `lines_live`.`user_ip` LIKE ? OR `lines_live`.`container` LIKE ? OR FROM_UNIXTIME(`lines_live`.`date_start`) LIKE ? OR `lines_live`.`geoip_country_code` LIKE ? OR `lines`.`username` LIKE ? OR `mag_devices`.`mac` LIKE ? OR `enigma2_devices`.`mac` LIKE ? OR `streams`.`stream_display_name` LIKE ?)';
- }
- if (0 >= intval(RequestManager::getAll()['stream'])) {
- } else {
- $rWhere[] = '`lines_live`.`stream_id` = ?';
- $rWhereV[] = RequestManager::getAll()['stream'];
- }
- if (0 >= intval(RequestManager::getAll()['user'])) {
- } else {
- $rWhere[] = '`lines`.`member_id` = ?';
- $rWhereV[] = RequestManager::getAll()['user'];
- }
- if (0 >= intval(RequestManager::getAll()['line'])) {
- } else {
- $rWhere[] = '`lines_live`.`user_id` = ?';
- $rWhereV[] = RequestManager::getAll()['line'];
- }
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `lines_live` LEFT JOIN `lines` ON `lines_live`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_live`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_live`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_live`.`user_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `mag_devices`.`mag_id`, `enigma2_devices`.`device_id`, `lines`.`is_e2`, `lines`.`is_mag`, `lines_live`.`activity_id`, `lines_live`.`divergence`, `lines_live`.`user_id`, `lines_live`.`stream_id`, `streams`.`series_no`, `lines`.`is_restreamer`, `lines_live`.`isp`, `lines_live`.`server_id`, `lines_live`.`user_agent`, `lines_live`.`user_ip`, `lines_live`.`container`, `lines_live`.`uuid`, `lines_live`.`date_start`, `lines_live`.`geoip_country_code`, IF(`lines`.`is_mag`, `mag_devices`.`mac`, IF(`lines`.`is_e2`, `enigma2_devices`.`mac`, `lines`.`username`)) AS `username`, `streams`.`stream_display_name`, `streams`.`type` FROM `lines_live` LEFT JOIN `lines` ON `lines_live`.`user_id` = `lines`.`id` LEFT JOIN `streams` ON `lines_live`.`stream_id` = `streams`.`id` LEFT JOIN `mag_devices` ON `mag_devices`.`user_id` = `lines_live`.`user_id` LEFT JOIN `enigma2_devices` ON `enigma2_devices`.`user_id` = `lines_live`.`user_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- $rRows = $db->get_rows();
- }
- }
- }
- if (0 >= count($rRows)) {
- } else {
- foreach ($rRows as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['divergence'] <= 50) {
- $rDivergence = '
';
- } else {
- if ($rRow['divergence'] <= 80) {
- $rDivergence = '
';
- } else {
- $rDivergence = '
';
- }
- }
- if ($rRow['is_mag']) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- if ($rRow['is_e2']) {
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rUsername = "
" . $rRow['username'] . '';
- }
- }
- $rChannel = $rRow['stream_display_name'];
- if (0 < strlen($rRow['geoip_country_code'])) {
- $rGeoCountry = "

";
- } else {
- $rGeoCountry = '';
- }
- if ($rRow['user_ip']) {
- $rIP = $rGeoCountry . "
" . $rRow['user_ip'] . '';
- } else {
- $rIP = '';
- }
- $rPlayer = trim(explode('(', $rRow['user_agent'])[0]);
- $rDuration = intval(time()) - intval($rRow['date_start']);
- $rColour = 'success';
- if (86400 <= $rDuration) {
- $rDuration = sprintf('%02dd %02dh', $rDuration / 86400, ($rDuration / 3600) % 24);
- $rColour = 'danger';
- } else {
- if (3600 <= $rDuration) {
- if (14400 < $rDuration) {
- $rColour = 'warning';
- } else {
- if (43200 >= $rDuration) {
- } else {
- $rColour = 'danger';
- }
- }
- $rDuration = sprintf('%02dh %02dm', $rDuration / 3600, ($rDuration / 60) % 60);
- } else {
- $rDuration = sprintf('%02dm %02ds', ($rDuration / 60) % 60, $rDuration % 60);
- }
- }
- $rDuration = "
';
- $rButtons = "
";
- $rReturn['data'][] = array($rRow['activity_id'], $rDivergence, $rUsername, $rChannel, $rPlayer, $rRow['isp'], $rIP, $rDuration, strtoupper($rRow['container']), $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- } else {
- exit();
- }
- } else {
- if ($rType == 'reg_user_logs') {
- $rOrder = array('`users_logs`.`id`', '`users`.`username`', '`users_logs`.`log_id`', '`users_logs`.`type`, `users_logs`.`action`', '`users_logs`.`cost`', '`users_logs`.`credits_after`', '`users_logs`.`date`');
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`users_logs`.`owner` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 3) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`users`.`username` LIKE ? OR `users_logs`.`type` LIKE ? OR `users_logs`.`action` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['range'])) {
- } else {
- $rStartTime = substr(RequestManager::getAll()['range'], 0, 10);
- $rEndTime = substr(RequestManager::getAll()['range'], strlen(RequestManager::getAll()['range']) - 10, 10);
- if ($rStartTime = strtotime($rStartTime . ' 00:00:00')) {
- } else {
- $rStartTime = null;
- }
- if ($rEndTime = strtotime($rEndTime . ' 23:59:59')) {
- } else {
- $rEndTime = null;
- }
- if (!($rStartTime && $rEndTime)) {
- } else {
- $rWhere[] = '(`users_logs`.`date` >= ? AND `users_logs`.`date` <= ?)';
- $rWhereV[] = $rStartTime;
- $rWhereV[] = $rEndTime;
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'])) {
- } else {
- $rWhere[] = '`users_logs`.`owner` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rPackages = getPackages();
- $rQuery = 'SELECT `users`.`username`, `users_logs`.`id`, `users_logs`.`owner`, `users_logs`.`type`, `users_logs`.`action`, `users_logs`.`log_id`, `users_logs`.`package_id`, `users_logs`.`cost`, `users_logs`.`credits_after`, `users_logs`.`date`, `users_logs`.`deleted_info` FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if (in_array($rRow['owner'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rOwner = "
" . $rRow['username'] . '';
- } else {
- $rOwner = "
" . $rRow['username'] . "
(indirect)";
- }
- $rDevice = array('line' => 'User Line', 'mag' => 'MAG Device', 'enigma' => 'Enigma2 Device', 'user' => 'Reseller')[$rRow['type']];
- switch ($rRow['action']) {
- case 'new':
- if ($rRow['package_id']) {
- $rText = 'Created New ' . $rDevice . ' with Package: ' . $rPackages[$rRow['package_id']]['package_name'];
- } else {
- $rText = 'Created New ' . $rDevice;
- }
- break;
- case 'extend':
- if ($rRow['package_id']) {
- $rText = 'Extended ' . $rDevice . ' with Package: ' . $rPackages[$rRow['package_id']]['package_name'];
- } else {
- $rText = 'Extended ' . $rDevice;
- }
- break;
- case 'edit':
- $rText = 'Edited ' . $rDevice;
- break;
- case 'enable':
- $rText = 'Enabled ' . $rDevice;
- break;
- case 'disable':
- $rText = 'Disabled ' . $rDevice;
- break;
- case 'delete':
- $rText = 'Deleted ' . $rDevice;
- break;
- case 'send_event':
- $rText = 'Sent Event to ' . $rDevice;
- break;
- case 'adjust_credits':
- $rText = 'Adjusted Credits by ' . $rRow['cost'];
- break;
- }
- $rLineInfo = null;
- switch ($rRow['type']) {
- case 'line':
- $rLine = UserRepository::getLineById($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['username'] . '';
- }
- break;
- case 'user':
- $rLine = UserRepository::getRegisteredUserById($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['username'] . '';
- }
- break;
- case 'mag':
- $rLine = getMag($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['mac'] . '';
- }
- break;
- case 'enigma':
- $rLine = getEnigma($rRow['log_id']);
- if (!$rLine) {
- } else {
- $rLineInfo = "
" . $rLine['mac'] . '';
- }
- break;
- }
- if ($rLineInfo) {
- } else {
- $rDeletedInfo = json_decode($rRow['deleted_info'], true);
- if (is_array($rDeletedInfo)) {
- if (isset($rDeletedInfo['mac'])) {
- $rLineInfo = "
" . $rDeletedInfo['mac'] . '';
- } else {
- $rLineInfo = "
" . $rDeletedInfo['username'] . '';
- }
- } else {
- $rLineInfo = "
DELETED";
- }
- }
- $rReturn['data'][] = array($rRow['id'], $rOwner, $rLineInfo, $rText, number_format($rRow['cost'], 0), number_format($rRow['credits_after'], 0), date($rSettings['datetime_format'], $rRow['date']));
- } else {
- unset($rRow['deleted_info']);
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- if ($rType != 'reg_users') {
- } else {
- if ($rPermissions['create_sub_resellers']) {
- $rOrder = array('`users`.`id`', '`users`.`username`', '`r`.`username`', '`users`.`ip`', '`users`.`status`', '`users`.`credits`', '`user_count`', '`users`.`last_login`', false);
- if (isset(RequestManager::getAll()['order']) && 0 < strlen(RequestManager::getAll()['order'][0]['column'])) {
- $rOrderRow = intval(RequestManager::getAll()['order'][0]['column']);
- } else {
- $rOrderRow = 0;
- }
- $rWhere = $rWhereV = array();
- $rWhere[] = '`users`.`owner_id` IN (' . implode(',', $rUserInfo['reports']) . ')';
- if (0 >= strlen(RequestManager::getAll()['search']['value'])) {
- } else {
- foreach (range(1, 9) as $rInt) {
- $rWhereV[] = '%' . RequestManager::getAll()['search']['value'] . '%';
- }
- $rWhere[] = '(`users`.`id` LIKE ? OR `users`.`username` LIKE ? OR `users`.`notes` LIKE ? OR `r`.`username` LIKE ? OR FROM_UNIXTIME(`users`.`date_registered`) LIKE ? OR FROM_UNIXTIME(`users`.`last_login`) LIKE ? OR `users`.`email` LIKE ? OR `users`.`ip` LIKE ? OR `users_groups`.`group_name` LIKE ?)';
- }
- if (0 >= strlen(RequestManager::getAll()['filter'])) {
- } else {
- if (RequestManager::getAll()['filter'] == 1) {
- $rWhere[] = '`users`.`status` = 1';
- } else {
- if (RequestManager::getAll()['filter'] != 2) {
- } else {
- $rWhere[] = '`users`.`status` = 0';
- }
- }
- }
- if (0 >= strlen(RequestManager::getAll()['reseller'])) {
- } else {
- $rWhere[] = '`users`.`owner_id` = ?';
- $rWhereV[] = RequestManager::getAll()['reseller'];
- }
- if (0 < count($rWhere)) {
- $rWhereString = 'WHERE ' . implode(' AND ', $rWhere);
- } else {
- $rWhereString = '';
- }
- if (!$rOrder[$rOrderRow]) {
- } else {
- $rOrderDirection = (strtolower(RequestManager::getAll()['order'][0]['dir']) === 'desc' ? 'desc' : 'asc');
- $rOrderBy = 'ORDER BY ' . $rOrder[$rOrderRow] . ' ' . $rOrderDirection;
- }
- $rCountQuery = 'SELECT COUNT(*) AS `count` FROM `users` LEFT JOIN `users_groups` ON `users_groups`.`group_id` = `users`.`member_group_id` LEFT JOIN `users` AS `r` on `r`.`id` = `users`.`owner_id` ' . $rWhereString . ';';
- $db->query($rCountQuery, ...$rWhereV);
- if ($db->num_rows() == 1) {
- $rReturn['recordsTotal'] = $db->get_row()['count'];
- } else {
- $rReturn['recordsTotal'] = 0;
- }
- $rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
- if (0 >= $rReturn['recordsTotal']) {
- } else {
- $rQuery = 'SELECT `users`.`id`, `users`.`status`, `users_groups`.`is_reseller`, `users`.`notes`, `users`.`owner_id`, `users`.`credits`, `users`.`username`, `users`.`email`, `users`.`ip`, FROM_UNIXTIME(`users`.`date_registered`) AS `date_registered`, FROM_UNIXTIME(`users`.`last_login`) AS `last_login`, `r`.`username` as `owner_username`, `users_groups`.`group_name`, `users`.`status`, (SELECT COUNT(`id`) FROM `lines` WHERE `member_id` = `users`.`id`) AS `user_count` FROM `users` LEFT JOIN `users_groups` ON `users_groups`.`group_id` = `users`.`member_group_id` LEFT JOIN `users` AS `r` on `r`.`id` = `users`.`owner_id` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
- $db->query($rQuery, ...$rWhereV);
- if (0 >= $db->num_rows()) {
- } else {
- foreach ($db->get_rows() as $rRow) {
- if (!$rIsAPI) {
- if ($rRow['status'] == 1) {
- $rStatus = '
';
- } else {
- $rStatus = '
';
- }
- if ($rRow['last_login']) {
- } else {
- $rRow['last_login'] = 'NEVER';
- }
- $rButtons = '
';
- if (0 < strlen($rRow['notes'])) {
- $rButtons .= '
';
- } else {
- $rButtons .= '
';
- }
- if (in_array($rRow['id'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rButtons .= '
';
- $rUsername = "
" . $rRow['username'] . '';
- } else {
- $rButtons .= '
';
- $rUsername = "
" . $rRow['username'] . "
(indirect)";
- }
- $rButtons .= '
';
- if ($rRow['status'] == 1) {
- $rButtons .= '
";
- } else {
- $rButtons .= '
";
- }
- if (!$rPermissions['delete_users']) {
- } else {
- $rButtons .= '
";
- }
- $rButtons .= '
';
- if (0 < strlen($rRow['ip'])) {
- $rIP = "
" . $rRow['ip'] . '';
- } else {
- $rIP = '';
- }
- if ($rRow['is_reseller']) {
- $rCredits = '
';
- } else {
- $rCredits = '
';
- }
- if (0 < $rRow['user_count']) {
- $rUserCount = '
';
- } else {
- $rUserCount = '
';
- }
- if (in_array($rRow['owner_id'], array_merge($rPermissions['direct_reports'], array($rUserInfo['id'])))) {
- $rOwner = "
" . $rRow['owner_username'] . '';
- } else {
- $rOwner = "
" . $rRow['owner_username'] . "
(indirect)";
- }
- $rReturn['data'][] = array("
" . $rRow['id'] . '', $rUsername, $rOwner, $rIP, $rStatus, $rCredits, $rUserCount, $rRow['last_login'], $rButtons);
- } else {
- $rReturn['data'][] = filterrow($rRow, RequestManager::getAll()['show_columns'], RequestManager::getAll()['hide_columns']);
- }
- }
- }
- }
- echo json_encode($rReturn);
- exit();
- }
- exit();
- }
- }
-} else {
- echo json_encode($rReturn);
- exit();
-}
-function filterRow($rRow, $rShow, $rHide) {
- if ($rShow || $rHide) {
- $rReturn = array();
- foreach (array_keys($rRow) as $rKey) {
- if ($rShow) {
- if (!in_array($rKey, $rShow)) {
- } else {
- $rReturn[$rKey] = $rRow[$rKey];
- }
- } else {
- if (!$rHide) {
- } else {
- if (in_array($rKey, $rHide)) {
- } else {
- $rReturn[$rKey] = $rRow[$rKey];
- }
- }
- }
- }
- return $rReturn;
- } else {
- return $rRow;
- }
-}
diff --git a/src/includes/data/permissions.php b/src/includes/data/permissions.php
deleted file mode 100644
index 6b8430a0..00000000
--- a/src/includes/data/permissions.php
+++ /dev/null
@@ -1,124 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-$rPermissionKeys = array(
- 'add_rtmp',
- 'add_bouquet',
- 'add_cat',
- 'add_e2',
- 'add_epg',
- 'add_episode',
- 'add_group',
- 'add_mag',
- 'add_movie',
- 'add_packages',
- 'add_radio',
- 'add_reguser',
- 'add_server',
- 'add_stream',
- 'tprofile',
- 'add_series',
- 'add_user',
- 'block_ips',
- 'block_isps',
- 'block_uas',
- 'create_channel',
- 'edit_bouquet',
- 'edit_cat',
- 'channel_order',
- 'edit_cchannel',
- 'edit_e2',
- 'epg_edit',
- 'edit_episode',
- 'folder_watch_settings',
- 'settings',
- 'edit_group',
- 'edit_mag',
- 'edit_movie',
- 'edit_package',
- 'edit_radio',
- 'edit_reguser',
- 'edit_server',
- 'edit_stream',
- 'edit_series',
- 'edit_user',
- 'fingerprint',
- 'import_episodes',
- 'import_movies',
- 'import_streams',
- 'database',
- 'mass_delete',
- 'mass_sedits_vod',
- 'mass_sedits',
- 'mass_edit_users',
- 'mass_edit_lines',
- 'mass_edit_mags',
- 'mass_edit_enigmas',
- 'mass_edit_streams',
- 'mass_edit_radio',
- 'mass_edit_reguser',
- 'ticket',
- 'subreseller',
- 'stream_tools',
- 'bouquets',
- 'categories',
- 'client_request_log',
- 'connection_logs',
- 'manage_cchannels',
- 'credits_log',
- 'index',
- 'manage_e2',
- 'epg',
- 'folder_watch',
- 'folder_watch_output',
- 'mng_groups',
- 'live_connections',
- 'login_logs',
- 'manage_mag',
- 'manage_events',
- 'movies',
- 'mng_packages',
- 'player',
- 'process_monitor',
- 'radio',
- 'mng_regusers',
- 'reg_userlog',
- 'rtmp',
- 'servers',
- 'stream_errors',
- 'streams',
- 'subresellers',
- 'manage_tickets',
- 'tprofiles',
- 'series',
- 'users',
- 'episodes',
- 'edit_tprofile',
- 'folder_watch_add',
- 'add_code',
- 'add_hmac',
- 'block_asns',
- 'panel_logs',
- 'quick_tools',
- 'restream_logs'
-);
-
-$rPermissions = array();
-foreach ($rPermissionKeys as $rPermissionKey) {
- $rPermissions[] = array(
- $rPermissionKey,
- $language::get('permission_' . $rPermissionKey),
- $language::get('permission_' . $rPermissionKey . '_text')
- );
-}
-
-return $rPermissions;
diff --git a/src/includes/libs/AsyncFileOperations.php b/src/includes/libs/AsyncFileOperations.php
deleted file mode 100644
index 433bdd05..00000000
--- a/src/includes/libs/AsyncFileOperations.php
+++ /dev/null
@@ -1,348 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- *
- * A PHP class created specifically for the XC_VM project to perform
- * efficient non-blocking file system operations.
- *
- * The class replaces CPU-heavy polling and blocking sleep() calls with
- * optimized mechanisms such as inotify-based monitoring (when available)
- * and adaptive file state polling as a fallback.
- *
- * Primary goals:
- * - Reduce CPU usage in long-running PHP processes
- * - Provide asynchronous-style file existence and modification checks
- * - Enable scalable filesystem monitoring without busy-wait loops
- */
-
-class AsyncFileOperations {
- /**
- * File existence cache with TTL
- * @var array
- */
- private static $fileCache = [];
-
- /**
- * Cache TTL in microseconds (100ms)
- * @var int
- */
- private static $cacheTTL = 100000;
-
- /**
- * Non-blocking file existence check with intelligent polling
- * Uses inotify if available, otherwise cached checks
- *
- * @param string $file File path to check
- * @param int $maxRetries Maximum retry attempts
- * @param int $delayMs Delay between retries in milliseconds
- * @return bool
- */
- public static function awaitFileExists($file, $maxRetries = 300, $delayMs = 10) {
- // First, quick check
- if (file_exists($file)) {
- self::clearFileCache($file);
- return true;
- }
-
- // Try inotify monitoring if available
- if (function_exists('inotify_init')) {
- return self::awaitFileWithInotify($file, $maxRetries, $delayMs);
- }
-
- // Fallback to optimized polling
- return self::awaitFileWithPolling($file, $maxRetries, $delayMs);
- }
-
- /**
- * Wait for file using inotify (Linux)
- * Zero-CPU-usage waiting when file system changes
- *
- * @param string $file File path to monitor
- * @param int $maxRetries Maximum retry attempts
- * @param int $delayMs Delay between fallback polls
- * @return bool
- */
- private static function awaitFileWithInotify($file, $maxRetries, $delayMs) {
- try {
- $directory = dirname($file);
- $filename = basename($file);
-
- $inotify = @inotify_init();
- if ($inotify === false) {
- return self::awaitFileWithPolling($file, $maxRetries, $delayMs);
- }
-
- // Watch directory for file creation
- @inotify_add_watch($inotify, $directory, IN_CREATE | IN_MOVED_TO | IN_CLOSE_WRITE);
-
- $checkCount = 0;
- $timeout = intval($maxRetries * max(1, intval($delayMs / 100)));
-
- while ($checkCount < $maxRetries) {
- if (file_exists($file)) {
- @fclose($inotify);
- return true;
- }
-
- // Wait for inotify events with timeout
- $events = @inotify_read($inotify);
-
- if ($events === false || !is_array($events)) {
- usleep(max(1000, $delayMs * 1000));
- }
-
- $checkCount++;
- }
-
- @fclose($inotify);
- return false;
- } catch (Exception $e) {
- return self::awaitFileWithPolling($file, $maxRetries, $delayMs);
- }
- }
-
- /**
- * Wait for file using optimized polling
- * Efficient busy-wait replacement that reduces CPU usage
- *
- * @param string $file File path to check
- * @param int $maxRetries Maximum retry attempts
- * @param int $delayMs Delay between retries in milliseconds
- * @return bool
- */
- private static function awaitFileWithPolling($file, $maxRetries = 300, $delayMs = 10) {
- $microDelay = max(1000, $delayMs * 1000); // Convert to microseconds
-
- for ($i = 0; $i < $maxRetries; $i++) {
- // Check with stat() for better performance
- if (@stat($file) !== false) {
- return true;
- }
-
- // Use adaptive sleep/usleep with early exit on events
- usleep($microDelay);
- }
-
- return false;
- }
-
- /**
- * Non-blocking read file content
- * Returns false if file doesn't exist or unreadable
- *
- * @param string $file File path
- * @param bool $useCache Use cache if available
- * @return string|false
- */
- public static function readFile($file, $useCache = true) {
- // Check cache first
- if ($useCache && isset(self::$fileCache[$file])) {
- $cached = self::$fileCache[$file];
- if (microtime(true) - $cached['time'] < self::$cacheTTL) {
- return $cached['content'];
- }
- unset(self::$fileCache[$file]);
- }
-
- // Use stat for quick check
- $stat = @stat($file);
- if ($stat === false) {
- return false;
- }
-
- // Read with size limit to prevent memory issues
- $maxReadSize = 1024 * 1024; // 1MB limit
- if ($stat['size'] > $maxReadSize) {
- return false;
- }
-
- $content = @file_get_contents($file);
-
- if ($content !== false && $useCache) {
- self::$fileCache[$file] = [
- 'content' => $content,
- 'time' => microtime(true)
- ];
- }
-
- return $content;
- }
-
- /**
- * Batch check multiple files existence
- * More efficient than individual checks
- *
- * @param array $files Array of file paths
- * @return array Array with file => bool mapping
- */
- public static function checkFilesExists(array $files) {
- $results = [];
- foreach ($files as $file) {
- $results[$file] = @stat($file) !== false;
- }
- return $results;
- }
-
- /**
- * Wait for ANY file from list to exist
- * Returns on first match or after timeout
- *
- * @param array $files Array of file paths
- * @param int $maxRetries Maximum retry attempts
- * @param int $delayMs Delay between retries
- * @return string|false File path that exists, or false
- */
- public static function awaitAnyFileExists(array $files, $maxRetries = 300, $delayMs = 10) {
- $microDelay = max(1000, $delayMs * 1000);
-
- for ($i = 0; $i < $maxRetries; $i++) {
- foreach ($files as $file) {
- if (@stat($file) !== false) {
- return $file;
- }
- }
- usleep($microDelay);
- }
-
- return false;
- }
-
- /**
- * Adaptive wait with exponential backoff
- * Starts with short waits, then increases delay
- *
- * @param string $file File path to monitor
- * @param int $maxRetries Maximum retry attempts
- * @param int $initialDelayMs Initial delay in milliseconds
- * @return bool
- */
- public static function awaitFileExistsAdaptive($file, $maxRetries = 300, $initialDelayMs = 10) {
- $delay = max(1000, $initialDelayMs * 1000); // Start in microseconds
- $maxDelay = 500000; // Cap at 500ms
-
- for ($i = 0; $i < $maxRetries; $i++) {
- if (@stat($file) !== false) {
- return true;
- }
-
- usleep($delay);
-
- // Increase delay exponentially but cap it
- $delay = min($maxDelay, intval($delay * 1.2));
- }
-
- return false;
- }
-
- /**
- * Monitor file for changes (mtime)
- * More efficient than polling
- *
- * @param string $file File path
- * @param int $timeoutSeconds Maximum wait time
- * @return bool True if file was modified
- */
- public static function awaitFileModified($file, $timeoutSeconds = 30) {
- $stat = @stat($file);
- if ($stat === false) {
- return false;
- }
-
- $originalMtime = $stat['mtime'];
- $endTime = time() + $timeoutSeconds;
-
- while (time() < $endTime) {
- $currentStat = @stat($file);
-
- if ($currentStat === false) {
- return false;
- }
-
- if ($currentStat['mtime'] > $originalMtime) {
- return true;
- }
-
- usleep(50000); // 50ms check interval
- }
-
- return false;
- }
-
- /**
- * Clear cache for specific file
- * @param string $file File path
- */
- public static function clearFileCache($file = null) {
- if ($file === null) {
- self::$fileCache = [];
- } else {
- unset(self::$fileCache[$file]);
- }
- }
-
- /**
- * Get cache statistics for debugging
- * @return array
- */
- public static function getCacheStats() {
- return [
- 'cached_files' => count(self::$fileCache),
- 'cache_memory' => memory_get_usage(true),
- ];
- }
-
- /**
- * Replacement for usleep with select()
- * More CPU-efficient than usleep in loops
- *
- * @param int $microseconds Sleep duration
- */
- public static function efficientSleep($microseconds) {
- if ($microseconds < 1000) {
- usleep($microseconds);
- return;
- }
-
- // Use time_nanosleep() if available for precise non-blocking sleep
- if (function_exists('time_nanosleep')) {
- $sec = intdiv($microseconds, 1000000);
- $nsec = ($microseconds % 1000000) * 1000; // convert microsec to nanosec
- // suppress warnings on interrupted sleep
- @time_nanosleep($sec, $nsec);
- return;
- }
-
- // Fallback to usleep
- usleep($microseconds);
- }
-
- /**
- * Non-blocking file size check
- * @param string $file File path
- * @return int|false File size or false
- */
- public static function getFileSize($file) {
- $stat = @stat($file);
- return $stat !== false ? $stat['size'] : false;
- }
-
- /**
- * Check if multiple files exist in parallel fashion
- * Better than sequential checks
- *
- * @param array $files File paths to check
- * @return array Files that exist
- */
- public static function filterExistingFiles(array $files) {
- return array_filter($files, function ($file) {
- return @stat($file) !== false;
- });
- }
-}
diff --git a/src/includes/libs/Dropbox.php b/src/includes/libs/Dropbox.php
deleted file mode 100644
index e6639afb..00000000
--- a/src/includes/libs/Dropbox.php
+++ /dev/null
@@ -1,846 +0,0 @@
-
- * @copyright Fabian Schlieper 2017
- * @version 2.0.0
- * @license See LICENSE
- */
-class DropboxClient {
- public const API_URL = 'https://api.dropboxapi.com/';
- public const API_CONTENT_URL = 'https://content.dropboxapi.com/';
- public const BUFFER_SIZE = 4096;
- public const MAX_UPLOAD_CHUNK_SIZE = 157286400;
- public const UPLOAD_CHUNK_SIZE = 2097152;
-
- private $appParams;
- private $consumerToken;
- private $requestToken;
- private $accessToken;
- private $rootPath;
- private $useCurl;
- private $curlOptions;
- private $_redirectUri;
- private static $_curlHeadersRef;
-
- /**
- * DropboxClient constructor.
- *
- * @param array $app_params ['app_key' => ..., 'app_secret' => ..., 'app_full_access' => ...]
- *
- * @param string $_deprecatedLocale Deprecated.
- *
- * @throws DropboxException
- */
- public function __construct($app_params = array(), $_deprecatedLocale = 'en') {
- $this->appParams = $app_params;
- $this->consumerToken = array('t' => $this->appParams['app_key'], 's' => $this->appParams['app_secret']);
- $this->rootPath = (empty($app_params['app_full_access']) ? 'sandbox' : 'dropbox');
- $this->requestToken = null;
- $this->accessToken = null;
- $this->useCurl = function_exists('curl_init');
- }
-
- public function __wakeup() {
- if (!empty($this->accessToken['s'])) {
- $this->accessToken = null;
- }
- $this->useCurl = $this->useCurl && function_exists('curl_init');
- }
-
- /**
- * Sets whether to use cURL if its available or PHP HTTP wrappers otherwise
- *
- * @param boolean $use_it whether to use it or not
- * @param array $curlOptions
- *
- * @return bool Whether to actually use cURL (always false if not installed)
- * @throws DropboxException
- */
- public function SetUseCUrl($use_it, $curlOptions = array()) {
- if (!$use_it && !empty($curlOptions)) {
- throw new DropboxException('not using cURL but specified cURL options');
- }
-
- $this->curlOptions = $curlOptions;
-
- return $this->useCurl = $use_it && function_exists('curl_init');
- }
-
- /**
- * Step 1. Returns a URL the user must be redirected to in order to connect the app to their Dropbox account
- *
- * @param string $redirect_uri URL users are redirected after authorization
- * @param string $state Up to 500 bytes of arbitrary data passed back to $redirect_uri
- *
- * @return string URL
- */
- public function BuildAuthorizeUrl($redirect_uri, $state = '') {
- $this->_redirectUri = $redirect_uri;
-
- return 'https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=' . $this->appParams['app_key'] . '&redirect_uri=' . urlencode($redirect_uri) . '&state=' . urlencode($state);
- }
-
- /**
- * Step 2.
- *
- * @param string $code The code GET param Dropbox generates when HTTP-redirecting the client
- * @param string $redirect_uri The same redirect_uri as passed to BuildAuthorizeUrl() before, used for validation
- *
- * @return array
- * @throws DropboxException
- */
- public function GetBearerToken($code = '', $redirect_uri = '') {
- if (!empty($this->accessToken)) {
- return $this->accessToken;
- }
-
- if (empty($code)) {
- $code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
-
- if (empty($code)) {
- throw new DropboxException('Missing OAuth2 code parameter!');
- }
- }
-
- if (!empty($redirect_uri)) {
- $this->_redirectUri = $redirect_uri;
- }
-
- if (empty($this->_redirectUri)) {
- throw new DropboxException('Redirect URI unknown, please specify or call BuildAuthorizeUrl() before!');
- }
-
- $res = $this->apiCall('oauth2/token', array('code' => $code, 'grant_type' => 'authorization_code', 'client_id' => $this->appParams['app_key'], 'client_secret' => $this->appParams['app_secret'], 'redirect_uri' => $this->_redirectUri));
-
- if (empty($res) || empty($res->access_token)) {
- throw new DropboxException(sprintf('Could not get bearer token! (code: %s)', $code));
- }
-
- return $this->accessToken = array('t' => $res->access_token, 'account_id' => $res->account_id);
- }
-
- /**
- * Sets a previously retrieved (and stored) bearer token.
- *
- * @param array|object $token
- *
- * @throws DropboxException
- */
- public function SetBearerToken($token) {
- $token = (array) $token;
-
- if (empty($token['t'])) {
- throw new DropboxException('Passed invalid bearer token.');
- }
-
- $this->accessToken = $token;
- }
-
- /**
- * Checks if an access token has been set.
- *
- * @access public
- * @return boolean Authorized or not
- */
- public function IsAuthorized() {
- return !empty($this->accessToken) && !empty($this->accessToken['account_id']);
- }
-
- /**
- * Retrieves information about the user's account.
- *
- * @access public
- * @return object Account info object. See https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account
- */
- public function GetAccountInfo() {
- $info = $this->apiCall('2/users/get_current_account');
- $info->uid = $info->account_id;
- $info->name_details = $info->name;
- $info->display_name = $info->name->display_name;
-
- return $info;
- }
-
- /**
- * @param string $path
- * @param bool $recursive
- * @param bool $include_deleted
- *
- * @return mixed
- * @throws DropboxException
- */
- public function GetFiles($path = '', $recursive = false, $include_deleted = false) {
- if (is_object($path) && !empty($path->path)) {
- $path = $path->path;
- }
-
- if ($path === '/') {
- $path = '';
- }
-
- $res = $this->apiCall('2/files/list_folder', compact('path', 'recursive', 'include_deleted'));
- $entries = $res->entries;
-
- while ($res->has_more) {
- $res = $this->apiCall('2/files/list_folder/continue', array('cursor' => $res->cursor));
- $entries = array_merge($entries, $res->entries);
- }
-
- $entries_assoc = array();
-
- foreach ($entries as $entry) {
- $entries_assoc[trim($entry->path_display, '/')] = $entry;
- }
-
- return array_map(array(__CLASS__, 'compatMeta'), $entries_assoc);
- }
-
- /**
- * See https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
- *
- * @param $path
- * @param bool $include_deleted
- * @param null $rev
- *
- * @return mixed
- * @throws DropboxException
- */
- public function GetMetadata($path, $include_deleted = false, $rev = null) {
- if (is_object($path) && !empty($path->path)) {
- $path = $path->path;
- }
-
- if (!empty($rev)) {
- $path = 'rev:' . $rev;
- }
-
- return self::compatMeta($this->apiCall('2/files/get_metadata', compact('path', 'include_deleted')));
- }
-
- /**
- * Download a file from user's Dropbox to the web server
- *
- * @param string|object $path Dropbox path or metadata object of the file to download.
- * @param string $dest_path Local path for destination
- * @param string $rev Optional. The revision of the file to retrieve. This defaults to the most recent revision.
- * @param callback $progress_changed_callback Optional. Callback that will be called during download with 2 args: 1. bytes loaded, 2. file size
- *
- * @return object Dropbox file metadata
- * @throws DropboxException
- */
- public function DownloadFile($path, $dest_path = '', $rev = null, $progress_changed_callback = null) {
- if (is_object($path) && !empty($path->path)) {
- $path = $path->path;
- }
-
- if (empty($dest_path)) {
- $dest_path = basename($path);
- }
-
- $url = self::cleanUrl('https://content.dropboxapi.com/2/files/download');
-
- if (!empty($rev)) {
- $path = 'rev:' . $rev;
- }
-
- $context = $this->createRequestContext($url, compact('path'));
- $fh = @fopen($dest_path, 'wb');
-
- if ($fh === false) {
- throw new DropboxException('Could not create file ' . $dest_path . ' !');
- }
-
- if ($this->useCurl) {
- curl_setopt($context, CURLOPT_BINARYTRANSFER, true);
- curl_setopt($context, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($context, CURLOPT_FILE, $fh);
- $response_headers = array();
- self::execCurlAndClose($context, $response_headers);
- fclose($fh);
- $meta = self::getMetaFromHeaders($response_headers, true);
- $bytes_loaded = filesize($dest_path);
- } else {
- $rh = @fopen($url, 'rb', false, $context);
-
- if ($rh === false) {
- throw new DropboxException('HTTP request to ' . $url . ' failed!');
- }
-
- $s_meta = stream_get_meta_data($rh);
- $meta = self::getMetaFromHeaders($s_meta['wrapper_data'], true);
- $bytes_loaded = 0;
-
- while (!feof($rh)) {
- if (($s = fwrite($fh, fread($rh, 4096))) === false) {
- @fclose($rh);
- @fclose($fh);
-
- throw new DropboxException('Writing to file ' . $dest_path . ' failed!\'');
- }
-
- $bytes_loaded += $s;
-
- if (!empty($progress_changed_callback)) {
- call_user_func($progress_changed_callback, $bytes_loaded, $meta->bytes);
- }
- }
-
- fclose($rh);
- fclose($fh);
- }
-
- if ($meta->size != $bytes_loaded) {
- throw new DropboxException('Download size mismatch! (header:' . $meta->size . ' vs actual:' . $bytes_loaded . '; curl:' . $this->useCurl . ')');
- }
-
- return $meta;
- }
-
- public static function compatMeta($meta) {
- $meta->is_dir = $meta->{'.tag'} == 'folder';
- $meta->path = $meta->path_display;
- $meta->bytes = (isset($meta->size) ? $meta->size : 0);
-
- return $meta;
- }
-
- /**
- * Upload a file to dropbox
- *
- * @access public
- *
- * @param string $src_file Local file to upload
- * @param string $path Dropbox path for destination
- * @param bool $overwrite
- *
- * @return object Dropbox file metadata
- * @throws DropboxException
- */
- public function UploadFile($src_file, $path = '', $overwrite = true) {
- if (empty($path)) {
- $path = basename($src_file);
- }
-
- $path = self::toPath($path);
- $dropbox_bn = basename($path);
-
- if (strpos($dropbox_bn, '.') === false) {
- try {
- $meta = $this->GetMetadata($path);
-
- if ($meta && $meta->is_dir) {
- $path = self::toPath($path . '/' . basename($src_file));
- }
- } catch (Exception $e) {
- }
- }
-
- $file_size = filesize($src_file);
- $commit_params = array('path' => $path, 'mode' => $overwrite ? 'overwrite' : 'add', 'autorename' => true);
-
- if (2097152 < $file_size) {
- $fh = fopen($src_file, 'rb');
-
- if ($fh === false) {
- throw new DropboxException('Cannot open ' . $src_file . ' for reading!');
- }
-
- $offset = 0;
- $res = $this->apiCall('2/files/upload_session/start', array(), true);
- $session_id = $res->session_id;
-
- while (!feof($fh)) {
- $content = fread($fh, 2097152);
- $this->apiCall('2/files/upload_session/append_v2', array('cursor' => compact('session_id', 'offset')), true, $content);
- $offset += strlen($content);
- unset($content);
-
- if ($file_size <= $offset) {
- break;
- }
- }
-
- @fclose($fh);
-
- return $this->apiCall('2/files/upload_session/finish', array('cursor' => compact('session_id', 'offset'), 'commit' => $commit_params), true);
- } else {
- $content = file_get_contents($src_file);
-
- return $this->apiCall('2/files/upload', $commit_params, true, $content);
- }
- }
-
- /**
- * Get thumbnail for a specified image
- *
- * @access public
- *
- * @param $dropbox_file string Path to the image
- * @param $format string Image format of the thumbnail (jpeg or png)
- * @param bool $echo
- * @param $size string Thumbnail size (xs, s, m, l, xl)
- *
- * @return string Returns the thumbnail as binary image data
- */
- public function GetThumbnail($dropbox_file, $size = 's', $format = 'jpeg', $echo = false) {
- $path = self::toPath($dropbox_file);
- $size_transform = array('xs' => 'w32h32', 's' => 'w64h64', 'm' => 'w128h128', 'l' => 'w640h480', 'xl' => 'w1024h768');
-
- if (isset($size_transform[$size])) {
- $size = $size_transform[$size];
- }
-
- $url = 'https://content.dropboxapi.com/2/files/get_thumbnail';
- $context = $this->createRequestContext($url, compact('path', 'size', 'format'));
- $thumb = ($this->useCurl ? self::execCurlAndClose($context) : file_get_contents($url, false, $context));
-
- if ($echo) {
- header('Content-type: image/' . $format);
- echo $thumb;
- unset($thumb);
-
- return '';
- }
-
- return $thumb;
- }
-
- public function GetLink($path, $preview = true, $_short = true, &$expires = null) {
- $path = self::toPath($path);
-
- if (!$preview) {
- $data = $this->apiCall('2/files/get_temporary_link', array('path' => $path));
- $expires = (time() + 14400) - 60;
-
- return $data->link;
- } else {
- try {
- $url = $this->apiCall('2/sharing/create_shared_link_with_settings', array(
- 'path' => $path,
- 'settings' => array('requested_visibility' => 'public')
- ));
- } catch (DropboxException $ex) {
- if ($ex->getTag() == 'shared_link_already_exists') {
- $publicLinks = array_filter($this->apiCall('2/sharing/list_shared_links', array('path' => $path))->links, function ($link) {
- return ($link->{'.tag'} == 'file') && ($link->link_permissions->resolved_visibility->{'.tag'} == 'public');
- });
- $url = reset($publicLinks);
- } else {
- throw $ex;
- }
- }
-
- return $url->url;
- }
- }
-
- public function Delta($cursor) {
- return $this->apiCall('2/files/list_folder/continue', array_merge(compact('cursor'), array()));
- }
-
- public function LatestCursor($path = '', $include_media_info = false) {
- $res = $this->apiCall('2/files/list_folder/get_latest_cursor', compact('path', 'include_media_info'));
-
- return $res->cursor;
- }
-
- public function GetRevisions($path, $limit = 10) {
- $path = self::toPath($path);
-
- return $this->apiCall('2/files/list_revisions', compact('path', 'limit'))->entries;
- }
-
- public function Restore($dropbox_file, $rev) {
- if (is_object($dropbox_file) && !empty($dropbox_file->path)) {
- $dropbox_file = $dropbox_file->path;
- }
-
- return $this->apiCall('restore/' . $this->rootPath . '/' . $dropbox_file, compact('rev'));
- }
-
- public function Search($path, $query, $max_results = 1000, $include_deleted = false) {
- $path = self::toPath($path);
- $mode = ($include_deleted ? 'deleted_filename' : 'filename');
- $meta = array();
-
- foreach ($this->apiCall('2/files/search', compact('path', 'query', 'max_results', 'mode'))->matches as $match) {
- $meta[] = self::compatMeta($match->metadata);
- }
-
- return $meta;
- }
-
- public function GetCopyRef($dropbox_file, &$expires = null) {
- if (is_object($dropbox_file) && !empty($dropbox_file->path)) {
- $dropbox_file = $dropbox_file->path;
- }
-
- $ref = $this->apiCall('copy_ref/' . $this->rootPath . '/' . $dropbox_file, 'GET');
- $expires = strtotime($ref->expires);
-
- return $ref->copy_ref;
- }
-
- public function Copy($from_path, $to_path, $copy_ref = false) {
- if (is_object($from_path) && !empty($from_path->path)) {
- $from_path = $from_path->path;
- }
-
- return $this->apiCall('fileops/copy', array('root' => $this->rootPath, $copy_ref ? 'from_copy_ref' : 'from_path' => $from_path, 'to_path' => $to_path));
- }
-
- /**
- * Creates a new folder in the DropBox
- *
- * @access public
- *
- * @param $path string The path to the new folder to create
- * @param bool $autorename
- *
- * @return object Dropbox folder metadata
- */
- public function CreateFolder($path, $autorename = false) {
- $res = $this->apiCall('2/files/create_folder_v2', array('path' => $path, 'autorename' => $autorename));
- $res->metadata->{'.tag'} = 'folder';
-
- return self::compatMeta($res->metadata);
- }
-
- /**
- * Delete file or folder
- *
- * @param $path mixed The path or metadata of the file/folder to be deleted.
- *
- * @return object Dropbox metadata of deleted file or folder
- */
- public function Delete($path) {
- if (is_object($path) && !empty($path->path)) {
- $path = $path->path;
- }
-
- $res = $this->apiCall('2/files/delete_v2', array('path' => $path));
-
- return self::compatMeta($res->metadata);
- }
-
- public function Move($from_path, $to_path) {
- if (is_object($from_path) && !empty($from_path->path)) {
- $from_path = $from_path->path;
- }
-
- return $this->apiCall('fileops/move', array('root' => $this->rootPath, 'from_path' => $from_path, 'to_path' => $to_path));
- }
-
- private function createCurl($url, $http_context) {
- $ch = curl_init($url);
- $curl_opts = array(CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_BINARYTRANSFER => true);
- $curl_opts[CURLOPT_CUSTOMREQUEST] = $http_context['method'];
-
- if (!empty($http_context['content'])) {
- $curl_opts[CURLOPT_POSTFIELDS] = &$http_context['content'];
-
- if (defined('CURLOPT_POSTFIELDSIZE')) {
- $curl_opts[CURLOPT_POSTFIELDSIZE] = strlen($http_context['content']);
- }
- }
-
- $curl_opts[CURLOPT_HTTPHEADER] = array_map('trim', explode("\n", $http_context['header']));
-
- if (!empty($this->curlOptions) && is_array($this->curlOptions)) {
- $curl_opts = array_merge($curl_opts, $this->curlOptions);
- }
-
- curl_setopt_array($ch, $curl_opts);
-
- return $ch;
- }
-
- private static function _curlHeaderCallback($ch, $header) {
- self::$_curlHeadersRef[] = trim($header);
-
- return strlen($header);
- }
-
- private static function &execCurlAndClose($ch, &$out_response_headers = null) {
- if (is_array($out_response_headers)) {
- self::$_curlHeadersRef = &$out_response_headers;
- curl_setopt($ch, CURLOPT_HEADERFUNCTION, array(__CLASS__, '_curlHeaderCallback'));
- }
-
- $res = curl_exec($ch);
- $err_no = curl_errno($ch);
- $err_str = curl_error($ch);
- curl_close($ch);
-
- if ($err_no || ($res === false)) {
- throw new DropboxException('cURL-Error (' . $err_no . '): ' . $err_str);
- }
-
- return $res;
-
- return null;
- }
-
- /**
- * @param $url string
- * @param $params
- * @param string $content
- * @param int $bearer_token
- *
- * @return resource
- */
- private function createRequestContext($url, $params, &$content = '', $bearer_token = -1) {
- if ($bearer_token === -1) {
- $bearer_token = $this->accessToken['t'];
- }
-
- $http_context = array('method' => 'POST', 'header' => '', 'content' => '');
-
- if (strpos($url, '/oauth2/token') !== false) {
- $http_context['header'] .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
- $http_context['content'] = http_build_query($params);
- } else {
- if (!empty($bearer_token)) {
- $http_context['header'] .= 'Authorization: Bearer ' . $bearer_token . "\r\n";
- }
-
- if (empty($content) && (strpos($url, 'https://content.dropboxapi.com/') === false)) {
- if (!empty($params)) {
- $http_context['header'] .= 'Content-Type: application/json' . "\r\n";
- $http_context['content'] = json_encode($params);
- }
- } else {
- $http_context['header'] .= 'Dropbox-API-Arg: ' . str_replace('"', '"', json_encode((object) $params)) . "\r\n";
- $http_context['header'] .= 'Content-Type: application/octet-stream' . "\r\n";
-
- if (!empty($content)) {
- $http_context['content'] = $content;
- }
- }
- }
-
- if (strpos($url, 'https://content.dropboxapi.com/') === false) {
- $http_context['header'] .= 'Content-Length: ' . strlen($http_context['content']);
- }
-
- $http_context['header'] = trim($http_context['header']);
- $http_context['ignore_errors'] = true;
-
- return $this->useCurl ? $this->createCurl($url, $http_context) : stream_context_create(array('http' => $http_context));
- }
-
- /**
- * @param object $resp
- * @param string $context
- *
- * @return object
- * @throws DropboxException
- */
- private static function checkForError($resp, $context = null) {
- if (!empty($resp->error)) {
- throw new DropboxException($resp, $context);
- }
-
- return $resp;
- }
-
- /**
- * @param string $path
- * @param array $params
- * @param bool $content_call
- * @param string $content
- *
- * @return object
- * @throws DropboxException
- */
- private function doSingleCall($path, $params = array(), $content_call = false, &$content = null) {
- $url = self::cleanUrl(($content_call ? 'https://content.dropboxapi.com/' : 'https://api.dropboxapi.com/') . $path);
- $context = $this->createRequestContext($url, $params, $content);
- $json = ($this->useCurl ? self::execCurlAndClose($context) : file_get_contents($url, false, $context));
- $resp = json_decode($json);
-
- if (is_null($resp) && $content_call) {
- return null;
- }
-
- if (is_null($resp) && !empty($json)) {
- throw new DropboxException('apiCall(' . $path . ') failed: ' . $json . ' (URL was ' . $url . ')');
- }
-
- if ((($resp === false) || is_null($resp)) && !empty($json) && !$content_call) {
- throw new DropboxException('Error apiCall(' . $path . '): ' . $json);
- }
-
- return self::checkForError($resp, 'apiCall(' . $path . ')');
- }
-
- /**
- * @param object $target
- * @param object $part
- */
- private static function mergeContinue(&$target, $part) {
- $keys = array_keys(get_object_vars($target));
-
- foreach ($keys as $k) {
- if (is_array($target->{$k}) && !empty($part->{$k}) && is_array($part->{$k})) {
- $target->{$k} = array_merge($target->{$k}, $part->{$k});
- }
- }
-
- $target->has_more = $part->has_more;
- $target->cursor = $part->cursor;
- }
-
- /**
- * @param string $path
- * @param array $params
- * @param bool $content_call
- * @param string $content
- *
- * @return object
- * @throws DropboxException
- */
- private function apiCall($path, $params = array(), $content_call = false, &$content = null) {
- $resp = $this->doSingleCall($path, $params, $content_call, $content);
-
- if (!empty($resp->has_more) && (strpos($path, '/continue') === false)) {
- $path .= '/continue';
- }
-
- while (!$content_call && !empty($resp->has_more)) {
- if (empty($resp->cursor)) {
- throw new DropboxException('Unexpected response from ' . $path . ': has_more without cursor!');
- }
-
- $params['cursor'] = (is_string($resp->cursor) ? $resp->cursor : $resp->cursor->value);
- self::mergeContinue($resp, $this->doSingleCall($path, $params, $content_call, $content));
- }
-
- return $resp;
- }
-
- private static function getMetaFromHeaders(&$header_array, $throw_on_error = false) {
- $obj = json_decode(substr(@array_shift(array_filter($header_array, function ($s) {
- return stripos($s, 'dropbox-api-result:') === 0;
- })), 20));
-
- if ($throw_on_error && (empty($obj) || !is_object($obj))) {
- throw new DropboxException('Could not retrieve meta data from header data: ' . print_r($header_array, true));
- }
-
- if ($throw_on_error) {
- self::checkForError($obj, __FUNCTION__);
- }
-
- return self::compatMeta($obj);
- }
-
- private static function toPath($file_or_path) {
- if (is_object($file_or_path)) {
- $file_or_path = $file_or_path->path;
- }
-
- $file_or_path = '/' . trim($file_or_path, '/');
-
- if ($file_or_path == '/') {
- $file_or_path = '';
- }
-
- return $file_or_path;
- }
-
- private static function cleanUrl($url) {
- $p = substr($url, 0, 8);
- $url = str_replace('//', '/', str_replace('\\', '/', substr($url, 8)));
- $url = rawurlencode($url);
- $url = str_replace('%2F', '/', $url);
-
- return $p . $url;
- }
-
- public static function contentHashStream($stream, $chunksize = 8192) {
- static $BLOCK_SIZE = 4194304;
- $streamhasher = hash_init('sha256');
- $blockhasher = hash_init('sha256');
- $current_block = 1;
- $current_blocksize = 0;
-
- while (!feof($stream)) {
- $max_bytes_to_read = min($chunksize, $BLOCK_SIZE - $current_blocksize);
- $chunk = fread($stream, $max_bytes_to_read);
-
- if (strlen($chunk) == 0) {
- break;
- }
-
- hash_update($blockhasher, $chunk);
- $current_blocksize += $max_bytes_to_read;
-
- if ($current_blocksize == $BLOCK_SIZE) {
- $blockhash = hash_final($blockhasher, true);
- hash_update($streamhasher, $blockhash);
- $blockhasher = hash_init('sha256');
- ++$current_block;
- $current_blocksize = 0;
- }
- }
-
- if (0 < $current_blocksize) {
- $blockhash = hash_final($blockhasher, true);
- hash_update($streamhasher, $blockhash);
- }
-
- return hash_final($streamhasher);
- }
-
- public static function contentHashFile($localFileName) {
- $handle = fopen($localFileName, 'r');
- $hash = self::contentHashStream($handle);
- fclose($handle);
-
- return $hash;
- }
-
- /**
- * @deprecated
- * @throws DropboxException
- */
- public function GetRequestToken() {
- throw new DropboxException('GetRequestToken() has been removed with v2 API. Request tokens do not exist in OAuth2 anymore.');
- }
-
- /**
- * @deprecated
- * @throws DropboxException
- */
- public function GetAccessToken() {
- throw new DropboxException('GetAccessToken() has been removed with v2 API. Use GetBearerToken() instead!');
- }
-}
-
-class DropboxException extends Exception {
- private $tag;
-
- public function __construct($resp = null, $context = null) {
- if (is_null($resp)) {
- $el = error_get_last();
- $this->message = $el['message'];
- $this->file = $el['file'];
- $this->line = $el['line'];
- } elseif (is_object($resp) && isset($resp->error)) {
- $this->message = (empty($resp->error_description) ? json_encode($resp) . ($context ? ', in ' . $context : '') : $resp->error_description);
- $this->tag = (is_object($resp->error) ? $resp->error->{'.tag'} : $resp->error);
- } else {
- $this->message = $resp . ($context ? ', in ' . $context : '');
- }
- }
-
- public function getTag() {
- return $this->tag;
- }
-}
diff --git a/src/includes/libs/GithubReleases.php b/src/includes/libs/GithubReleases.php
deleted file mode 100644
index 2bf77db9..00000000
--- a/src/includes/libs/GithubReleases.php
+++ /dev/null
@@ -1,584 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- *
- * A PHP class created specifically for the XC_VM project to interact with the GitHub Releases API.
- * Provides methods to fetch release versions, changelogs, asset hashes, and GeoLite database information
- * with caching support.
- */
-
-class GitHubReleases {
- private $owner;
- private $repo;
- private $api_url;
- private $headers;
- private $timeout = 5; // Request timeout in seconds
- private $cache_file = '/home/xc_vm/tmp/gitapi'; // Cache file path
- private string $channel = 'stable'; // 'stable' или 'unstable'
- private $hash_file = 'hashes.md5';
- private $cache_ttl = 1800; // Cache TTL in seconds (30 minutes)
-
- /**
- * Initialize a GitHubReleases instance.
- *
- * @param string $owner Repository owner
- * @param string $repo Repository name
- * @param string $channel Update channel: 'stable' or 'unstable'
- * @param string|null $token GitHub API token
- */
- public function __construct(string $owner, string $repo, ?string $channel = 'stable', ?string $token = null) {
- $this->owner = $owner;
- $this->repo = $repo;
- $this->channel = in_array($channel, ['stable', 'unstable']) ? $channel : 'stable';
- $this->cache_file = "{$this->cache_file}_{$repo}_{$this->channel}"; // Уникальный кэш для канала
- $this->api_url = "https://api.github.com/repos/{$owner}/{$repo}/releases";
- $this->headers = $token ? [
- "Authorization: Bearer {$token}",
- 'Accept: application/vnd.github+json',
- 'X-GitHub-Api-Version: 2022-11-28'
- ] : [];
- }
-
- /**
- * Clear the cached release data by deleting the cache file.
- */
- public function clearCache(): void {
- if (file_exists($this->cache_file)) {
- unlink($this->cache_file);
- error_log("Cache cleared for {$this->owner}/{$this->repo} by deleting {$this->cache_file}");
- }
- }
-
- /**
- * Check if the cache file is still valid based on TTL.
- *
- * @return bool True if cache is valid, False otherwise.
- */
- private function isCacheValid(): bool {
- if (!file_exists($this->cache_file)) {
- return false;
- }
- $cache_timestamp = filemtime($this->cache_file);
- return (time() - $cache_timestamp) < $this->cache_ttl;
- }
-
- /**
- * Load cache from file.
- *
- * @return array|null The cached data, or null if the file doesn't exist or is invalid.
- */
- private function loadCache(): ?array {
- if (!file_exists($this->cache_file)) {
- return null;
- }
- $content = file_get_contents($this->cache_file);
- if ($content === false) {
- error_log("Failed to read cache file {$this->cache_file}");
- return null;
- }
- $data = json_decode($content, true);
- if (json_last_error() !== JSON_ERROR_NONE) {
- error_log("Failed to parse cache file {$this->cache_file}: " . json_last_error_msg());
- return null;
- }
- return $data;
- }
-
- /**
- * Save data to cache file with file locking to prevent race conditions.
- *
- * @param array $data The data to cache.
- * @return bool True on success, False on failure.
- */
- private function saveCache(array $data): bool {
- $json = json_encode($data);
- if ($json === false) {
- error_log("Failed to encode cache data to JSON");
- return false;
- }
-
- $file = fopen($this->cache_file, 'c');
- if ($file === false) {
- error_log("Failed to open cache file {$this->cache_file} for writing");
- return false;
- }
-
- if (flock($file, LOCK_EX)) {
- ftruncate($file, 0);
- fwrite($file, $json);
- fflush($file);
- flock($file, LOCK_UN);
- fclose($file);
- error_log("Cache saved to {$this->cache_file}");
- return true;
- } else {
- error_log("Failed to acquire lock on cache file {$this->cache_file}");
- fclose($file);
- return false;
- }
- }
-
- /**
- * Fetch all release versions (tags) from the GitHub repository, using cache if valid.
- *
- * @return array List of version tags in descending order (latest first).
- * @throws Exception If the request fails.
- */
- public function getReleases(): array {
- if ($this->isCacheValid()) {
- error_log("Using cached releases (channel: {$this->channel}) from {$this->cache_file}");
- $cache = $this->loadCache();
- if ($cache !== null) {
- $releases = $this->filterReleasesByChannel($cache);
- return array_values(array_map(fn($r) => $r['tag_name'], $releases));
- }
- }
-
- try {
- error_log("Fetching releases for {$this->owner}/{$this->repo} (channel: {$this->channel})");
- $response = $this->makeRequest($this->api_url);
- $data = json_decode($response, true);
- if ($data === null) {
- throw new Exception("Failed to parse API response: " . json_last_error_msg());
- }
-
- $filtered = $this->filterReleasesByChannel($data);
- $this->saveCache($data); // Сохраняем полные данные, фильтруем при использовании
-
- $releases = array_values(array_map(fn($r) => $r['tag_name'], $filtered));
- error_log("Retrieved " . count($releases) . " releases for channel '{$this->channel}'");
- return $releases;
- } catch (Exception $e) {
- error_log("Failed to fetch releases: " . $e->getMessage());
- throw $e;
- }
- }
-
- /**
- * Get the next version tag that comes after the specified current version.
- *
- * @param string $current_version The current version tag (e.g., "1.0.0").
- * @return string|null The next version tag, or null if it's the latest or not found.
- * @deprecated Use getLatestVersion() instead — sequential updates are no longer required.
- */
- public function getNextVersion(string $current_version): ?string {
- return $this->getLatestVersion($current_version);
- }
-
- /**
- * Get the latest available version that is newer than the current one.
- *
- * Unlike getNextVersion(), this skips intermediate versions and returns
- * the newest release directly, allowing jump updates.
- *
- * @param string $current_version The current version tag (e.g., "1.0.0").
- * @return string|null The latest version tag, or null if already up-to-date or version not found.
- */
- public function getLatestVersion(string $current_version): ?string {
- $releases = $this->getReleases();
-
- if (empty($releases)) {
- return null;
- }
-
- $latest = $releases[0];
-
- if (version_compare($latest, $current_version, '<=')) {
- return null;
- }
-
- return $latest;
- }
-
- /**
- * Retrieve the MD5 hash of a release asset from its corresponding hash file.
- *
- * @param string $version The release tag (e.g., "1.0.0").
- * @param string $asset_name The asset file name to get the hash for (e.g., "update.tar.gz").
- * @return string|null The MD5 hash string, or null if not found or invalid.
- */
- public function getAssetHash(string $version, string $asset_name): ?string {
- try {
- $hashURL = "https://github.com/{$this->owner}/{$this->repo}/releases/download/{$version}/{$this->hash_file}";
- $hash_response = $this->makeRequest($hashURL);
-
- $hash_text = trim($hash_response);
- $lines = explode("\n", $hash_text);
-
- foreach ($lines as $line) {
- $line = trim($line);
- if (empty($line)) {
- continue;
- }
- $parts = preg_split('/\s+/', $line, 2);
- if (count($parts) === 2 && $parts[1] === $asset_name) {
- error_log("Retrieved MD5 hash for {$asset_name} in version {$version}");
- return $parts[0];
- }
- }
- return null;
- } catch (Exception $e) {
- error_log("Failed to fetch asset hash: " . $e->getMessage());
- return null;
- }
- }
-
- /**
- * Retrieve the changelog for all releases from changelog.json files in JSON format.
- *
- * @param string $changelog_file_url Link to file with changelog.
- * @return array A JSON-compatible array containing the changelog.
- */
- public function getChangelog(string $changelog_file_url): array {
- try {
- if (!$this->isCacheValid()) {
- $response = $this->makeRequest($this->api_url);
- $data = json_decode($response, true);
- if ($data === null) {
- throw new Exception("Failed to parse API response: " . json_last_error_msg());
- }
- $this->saveCache($data);
- error_log("Updated cache for {$this->owner}/{$this->repo}");
- }
- $releases = $this->loadCache();
- if ($releases === null) {
- error_log("Invalid cache, unable to proceed");
- return [];
- }
-
- $response = $this->makeRequest($changelog_file_url);
- $changelog = json_decode($response, true);
- if ($changelog === null) {
- error_log("Failed to parse changelog JSON");
- return [];
- }
-
- $valid_versions = array_map(function ($release) {
- return $release['tag_name'] ?? '';
- }, $releases);
- $filtered_changelog = array_filter($changelog, function ($entry) use ($valid_versions) {
- return in_array($entry['version'] ?? '', $valid_versions);
- });
- $filtered_changelog = array_values($filtered_changelog);
- error_log("Successfully retrieved changelog with " . count($filtered_changelog) . " versions after filtering (original: " . count($changelog) . " versions)");
- return $filtered_changelog;
- } catch (Exception $e) {
- error_log("Failed to fetch changelog: " . $e->getMessage());
- return [];
- }
- }
-
- /**
- * Validate whether a version string follows the format X.Y.Z.
- *
- * @param string $version The version string to validate (e.g., "1.0.0").
- * @return bool True if valid, False otherwise.
- * @throws InvalidArgumentException If the version string is too long or contains invalid parts.
- */
- public static function isValidVersion(string $version): bool {
- if (!is_string($version)) {
- error_log("Version must be a string");
- return false;
- }
-
- if (strlen($version) > 20) {
- error_log("Version string too long");
- throw new InvalidArgumentException("Version string is too long");
- }
-
- if (!preg_match('/^[0-9]+\.[0-9]+\.[0-9]+$/', $version)) {
- error_log("Invalid version format: {$version}");
- return false;
- }
-
- $parts = explode('.', $version);
- if (count($parts) !== 3) {
- error_log("Version must have three parts: {$version}");
- return false;
- }
-
- foreach ($parts as $part) {
- $num = (int)$part;
- if ($num < 0) {
- error_log("Negative numbers are not allowed in version: {$version}");
- return false;
- }
- if (strlen($part) > 1 && $part[0] === '0') {
- error_log("Leading zeros are not allowed in version: {$version}");
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Make an HTTP request using cURL.
- *
- * @param string $url The URL to request.
- * @return string The response body.
- * @throws Exception If the request fails.
- */
- private function makeRequest(string $url): string {
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Vateron-Media/XC_VM');
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
-
- $response = curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $error = curl_error($ch);
- curl_close($ch);
-
- if ($response === false) {
- throw new Exception("cURL error: {$error}");
- }
-
- if ($http_code !== 200) {
- switch ($http_code) {
- case 404:
- error_log("Resource not found (404)");
- throw new Exception("Resource not found (404)");
- case 403:
- error_log("Access forbidden (403) - Check API rate limits or permissions");
- throw new Exception("Access forbidden (403)");
- case 500:
- error_log("Server error (500)");
- throw new Exception("Server error (500)");
- default:
- error_log("Unexpected HTTP status code: {$http_code}");
- throw new Exception("Unexpected HTTP status code: {$http_code}");
- }
- }
-
- return $response;
- }
-
- /**
- * Get update file details for a specific file type and version.
- *
- * @param string $file_type The type of update file (main, lb, lb_update).
- * @param string $version The current version tag (e.g., "1.0.0").
- * @return array|null Array with URL and MD5 hash, or null if no next version.
- * @throws Exception If the file type is invalid.
- */
- public function getUpdateFile(string $file_type, string $version) {
- switch ($file_type) {
- case "main":
- $update_file = "update.tar.gz";
- break;
- case "lb":
- $update_file = "loadbalancer.tar.gz";
- break;
- case "lb_update":
- $update_file = "loadbalancer_update.tar.gz";
- break;
- default:
- throw new Exception("Not valid file type");
- }
- $target_version = $this->getLatestVersion($version);
- if (is_null($target_version)) {
- $target_version = $version;
- }
- $upd_archive_url = "https://github.com/{$this->owner}/{$this->repo}/releases/download/{$target_version}/{$update_file}";
- $hash_md5 = $this->getAssetHash($target_version, $update_file);
-
- $data = ["url" => $upd_archive_url, "md5" => $hash_md5];
- return $data;
- }
-
- /**
- * Retrieves update information for the specified version
- *
- * @param string $version Current version to check for updates
- * @return array|null Array with update information or null in case of error
- * @throws InvalidArgumentException If an incorrect version is passed
- */
- public function getUpdate(string $version): ?array {
- try {
- $latest_version = $this->getLatestVersion($version);
- if ($latest_version === null) {
- error_log("No update available for version {$version} on channel '{$this->channel}'");
- return null;
- }
-
- $changelogUrl = "https://raw.githubusercontent.com/{$this->owner}/{$this->repo}_Update/refs/heads/main/changelog.json";
- $changelog = $this->getChangelog($changelogUrl);
-
- $url = "https://github.com/{$this->owner}/{$this->repo}/releases/tag/{$latest_version}";
-
- return [
- "version" => $latest_version,
- "changelog" => $changelog,
- "url" => $url
- ];
- } catch (Exception $e) {
- error_log("Error while fetching update: " . $e->getMessage());
- return null;
- }
- }
- /**
- * Retrieve the latest GeoLite database release information.
- *
- * This method fetches the latest release version from the repository,
- * builds download URLs for GeoLite2 database files (ASN, City, Country),
- * and prepares metadata including file paths, permissions, and MD5 hashes.
- *
- * @return array|null Returns an associative array with the latest version and file data,
- * or null if no releases are available.
- */
- public function getGeolite(): ?array {
- // Get all available releases from the repository
- $releases = $this->getReleases();
-
- // If there are no releases, return null
- if (empty($releases)) {
- return null;
- }
-
- // Take the latest release (the first in the list)
- $latest_version = $releases[0];
-
- // Prepare the list of data files
- $data_files = array();
-
- // Iterate over required GeoLite2 database files
- foreach (["GeoLite2-City.mmdb", "GeoLite2-Country.mmdb"] as $file) {
- // Construct the GitHub release download URL
- $file_url = "https://github.com/{$this->owner}/{$this->repo}/releases/download/{$latest_version}/{$file}";
-
- // Fetch the MD5 hash for file integrity verification
- $hash_md5 = $this->getAssetHash($latest_version, $file);
-
- // Add file information to the list
- $data_files[] = [
- "fileurl" => $file_url, // Remote file URL
- "path" => "/home/xc_vm/bin/maxmind/{$file}", // Local path where the file should be stored
- "permission" => "0750", // File permission
- "md5" => $hash_md5 // File hash (MD5)
- ];
- }
-
- // Prepare final data structure containing version and files metadata
- $data = [
- "version" => $latest_version,
- "files" => $data_files,
- ];
-
- // Return the release data
- return $data;
- }
-
- /**
- * Filter releases based on the selected channel.
- *
- * @param array $releases Raw releases from GitHub API
- * @return array Filtered releases
- */
- private function filterReleasesByChannel(array $releases): array {
- if ($this->channel === 'unstable') {
- return $releases; // Все релизы
- }
-
- // stable: только не pre-release
- return array_filter($releases, function ($release) {
- return empty($release['prerelease']);
- });
- }
-
- /**
- * Change the update channel and clear cache.
- *
- * @param string $channel 'stable' or 'unstable'
- */
- public function setChannel(string $channel): void {
- if (!in_array($channel, ['stable', 'unstable'])) {
- throw new InvalidArgumentException("Channel must be 'stable' or 'unstable'");
- }
- if ($this->channel !== $channel) {
- $this->channel = $channel;
- $this->cache_file = str_replace("_{$this->channel}", '', $this->cache_file) . "_{$channel}";
- $this->clearCache();
- error_log("Update channel changed to '{$channel}' and cache cleared");
- }
- }
-}
-
-/**
- * ------------------------------------------------------------
- * 🔧 Инициализация:
- *
- * $gh = new GitHubReleases("Vateron-Media", "XC_VM", 'stable');
- * // Можно передать токен для увеличения лимита API:
- * // $gh = new GitHubReleases("owner", "repo", "ghp_XXXXXXX");
- *
- * ------------------------------------------------------------
- *
- * 1. Получить список релизов:
- *
- * $releases = $gh->getReleases();
- * print_r($releases);
- *
- * ------------------------------------------------------------
- * 2. Получить последнюю доступную версию (прыжок на latest):
- *
- * $latest = $gh->getLatestVersion("1.0.0");
- * echo $latest; // e.g. "2.0.2" — пропускает промежуточные версии
- *
- * ------------------------------------------------------------
- * 3. getNextVersion() — алиас getLatestVersion() (deprecated):
- *
- * $next = $gh->getNextVersion("1.0.0"); // то же что getLatestVersion()
- *
- * ------------------------------------------------------------
- * 3. Проверить хэш файла из релиза:
- *
- * $hash = $gh->getAssetHash("1.2.0", "update.tar.gz");
- * echo $hash;
- *
- * ------------------------------------------------------------
- * 4. Загрузить changelog:
- *
- * $changelog = $gh->getChangelog("https://raw.githubusercontent.com/Vateron-Media/XC_VM_Update/refs/heads/main/changelog.json");
- * print_r($changelog);
- *
- * ------------------------------------------------------------
- * 5. Проверка корректности версии:
- *
- * var_dump(GitHubReleases::isValidVersion("1.0.0")); // true
- * var_dump(GitHubReleases::isValidVersion("01.0.0")); // false
- *
- * ------------------------------------------------------------
- * 6. Получение архива обновления:
- *
- * $upd = $gh->getUpdateFile("main", "1.0.0");
- * print_r($upd);
- *
- * ------------------------------------------------------------
- * 7. Проверить наличие обновления:
- *
- * $update = $gh->getUpdate("1.0.0");
- * print_r($update);
- *
- * ------------------------------------------------------------
- * 8. Получить информацию о GeoLite базах:
- *
- * $gh = new GitHubReleases("Vateron-Media", "XC_VM_Update");
- * $geo = $gh->getGeolite();
- * print_r($geo);
- *
- * ------------------------------------------------------------
- * ⚠️ Важно:
- * - Кеш хранится в /home/xc_vm/tmp/gitapi_repo
- * - TTL кеша: 30 минут (1800 сек)
- */
diff --git a/src/includes/libs/Logger.php b/src/includes/libs/Logger.php
deleted file mode 100644
index c6c2d2d0..00000000
--- a/src/includes/libs/Logger.php
+++ /dev/null
@@ -1,310 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-final class Logger {
- /** @var bool Whether development mode is enabled (errors are displayed on screen) */
- private static bool $development = false;
-
- /** @var string Full path to the log file */
- private static string $logFile;
-
- /**
- * Initializes error, exception, and fatal error handlers.
- *
- * @param bool $showErrors true for development mode (display errors), false for production
- * @param string $logFile Full path to the file where logs will be written
- */
- public static function init(bool $showErrors, string $logFile): void {
- self::$development = $showErrors;
- self::$logFile = $logFile;
-
- // Set custom handlers
- set_error_handler([self::class, 'handleError']);
- set_exception_handler([self::class, 'handleException']);
- register_shutdown_function([self::class, 'handleFatal']);
-
- if ($showErrors) {
- // In development mode, show all errors
- error_reporting(E_ERROR | E_WARNING);
- ini_set('display_errors', '1');
- ini_set('display_startup_errors', '1');
- } else {
- // In production, hide errors from the user
- error_reporting(0);
- ini_set('display_errors', '0');
- }
- }
-
- /* ================= ERRORS ================= */
-
- /**
- * Handler for regular PHP errors (trigger_error, warnings, notices, etc.).
- *
- * @param int $errno Error level (E_WARNING, E_NOTICE, etc.)
- * @param string $message Error message
- * @param string $file File where the error occurred
- * @param int $line Line number in the file
- *
- * @return bool true if the error was handled (prevents default PHP handler)
- */
- public static function handleError(
- int $errno,
- string $message,
- string $file,
- int $line
- ): bool {
- // Ignore suppressed errors (using @ operator)
- if (!(error_reporting() & $errno)) {
- return false;
- }
-
- self::log(
- self::mapErrorLevel($errno),
- $message,
- self::buildTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)),
- $file,
- $line
- );
-
- return true;
- }
-
- /* ================= EXCEPTIONS ================= */
-
- /**
- * Handler for uncaught exceptions.
- *
- * @param Throwable $e The uncaught exception
- */
- public static function handleException(Throwable $e): void {
- self::log(
- 'EXCEPTION',
- $e->getMessage(),
- self::buildExceptionTrace($e),
- $e->getFile(),
- $e->getLine()
- );
- }
-
- /* ================= FATAL ================= */
-
- /**
- * Handler for fatal errors (E_ERROR, E_PARSE, etc.) that terminate script execution.
- * Called via register_shutdown_function.
- */
- public static function handleFatal(): void {
- $error = error_get_last();
-
- // Process only true fatal errors
- if ($error && in_array($error['type'], [
- E_ERROR,
- E_PARSE,
- E_CORE_ERROR,
- E_COMPILE_ERROR
- ], true)) {
- self::log(
- 'FATAL',
- $error['message'],
- '', // Stack trace is not available for fatal errors
- $error['file'],
- $error['line']
- );
- }
- }
-
- /* ================= CORE LOG ================= */
-
- /**
- * Core logging method. Writes the event to the log file and optionally outputs it in development mode.
- *
- * @param string $type Event type (ERROR, WARNING, NOTICE, EXCEPTION, FATAL, etc.)
- * @param string $message Message text
- * @param string $trace Stack trace (optional)
- * @param string $file File where the event occurred
- * @param int $line Line number
- */
- public static function log(
- string $type,
- string $message,
- string $trace = '',
- string $file = '',
- int $line = 0
- ): void {
- $data = [
- 'type' => $type,
- 'log_message' => $message,
- 'file' => $file,
- 'line' => $line,
- 'log_extra' => $trace, // Process ID
- 'time' => time(), // Unix timestamp
- 'env' => php_sapi_name() // SAPI name (cli, fpm-fcgi, etc.)
- ];
-
- // Ensure log directory exists
- $logDir = dirname(self::$logFile);
- if (!is_dir($logDir)) {
- @mkdir($logDir, 0775, true);
- }
-
- // Write to file as base64-encoded JSON (easy to parse and prevents line corruption)
- file_put_contents(
- self::$logFile,
- base64_encode(json_encode($data, JSON_UNESCAPED_UNICODE)) . "\n",
- FILE_APPEND | LOCK_EX
- );
-
- // Set log file permissions if running as root (common in containers)
- if (function_exists('posix_geteuid') && posix_geteuid() === 0) {
- @chown(self::$logFile, 'xc_vm');
- @chgrp(self::$logFile, 'xc_vm');
- @chmod(self::$logFile, 0664);
- }
-
- // In development mode, display a readable message on screen
- if (self::$development) {
- self::output($data);
- }
- }
-
- /* ================= TRACE ================= */
-
- /**
- * Builds a stack trace for an exception chain (including previous exceptions).
- *
- * @param Throwable $e The exception
- *
- * @return string Formatted trace string
- */
- private static function buildExceptionTrace(Throwable $e): string {
- $out = [];
-
- do {
- // Main exception info
- $out[] = sprintf(
- "%s: %s in %s:%d",
- get_class($e),
- $e->getMessage(),
- $e->getFile(),
- $e->getLine()
- );
-
- // Call stack for the current exception
- foreach ($e->getTrace() as $i => $t) {
- $out[] = sprintf(
- "#%d %s(%s): %s()",
- $i,
- $t['file'] ?? '[internal]',
- $t['line'] ?? '?',
- $t['function']
- );
- }
-
- $e = $e->getPrevious();
- if ($e) {
- $out[] = "---- CAUSED BY ----";
- }
- } while ($e);
-
- return implode("\n", $out);
- }
-
- /**
- * Builds a stack trace from the array returned by debug_backtrace().
- *
- * @param array $trace Backtrace array
- *
- * @return string Formatted trace string
- */
- private static function buildTrace(array $trace): string {
- $out = [];
-
- foreach ($trace as $i => $t) {
- $out[] = sprintf(
- "#%d %s(%s): %s()",
- $i,
- $t['file'] ?? '[internal]',
- $t['line'] ?? '?',
- $t['function']
- );
- }
-
- return implode("\n", $out);
- }
-
- /* ================= HELPERS ================= */
-
- /**
- * Maps a PHP error constant to a human-readable string.
- *
- * @param int $errno Error level constant
- *
- * @return string Error type (ERROR, WARNING, NOTICE, INFO)
- */
- private static function mapErrorLevel(int $errno): string {
- return match ($errno) {
- E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR => 'ERROR',
- E_WARNING, E_USER_WARNING => 'WARNING',
- E_NOTICE, E_USER_NOTICE => 'NOTICE',
- default => 'INFO',
- };
- }
-
- /**
- * Outputs error/exception information to the screen in a readable format.
- * Format depends on the environment (CLI or Web).
- *
- * @param array $d Event data (from the log method)
- */
- private static function output(array $d): void {
- if (php_sapi_name() === 'cli') {
- // Color scheme for terminal
- $color = match ($d['type']) {
- 'FATAL', 'ERROR' => "\033[41m\033[97m", // red background, white text
- 'WARNING' => "\033[43m\033[30m", // yellow background, black text
- 'NOTICE' => "\033[44m\033[97m", // blue background, white text
- default => "\033[45m\033[97m", // magenta background, white text
- };
-
- echo "\n{$color} {$d['type']} \033[0m ";
- echo date('Y-m-d H:i:s', $d['time']) . "\n";
- echo "{$d['log_message']}\n";
- echo "{$d['file']}:{$d['line']}\n";
-
- if (!empty($d['log_extra'])) {
- echo str_repeat('-', 60) . "\n";
- echo $d['log_extra'] . "\n";
- }
- } else {
- // Web environment output
- echo "
";
- echo "
{$d['type']} ";
- echo "
" . date('Y-m-d H:i:s', $d['time']) . "";
- echo htmlspecialchars($d['log_message'], ENT_SUBSTITUTE) . "
";
- echo "
{$d['file']}:{$d['line']}";
-
- if (!empty($d['log_extra'])) {
- echo "
";
- echo htmlspecialchars($d['log_extra'], ENT_SUBSTITUTE);
- echo "
";
- }
- echo "
";
- }
- }
-}
diff --git a/src/includes/libs/TMDb/Collection.php b/src/includes/libs/TMDb/Collection.php
deleted file mode 100644
index 93c54052..00000000
--- a/src/includes/libs/TMDb/Collection.php
+++ /dev/null
@@ -1,84 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Collection {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Collection
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Collection's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Collection's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Collection's overview
- *
- * @return string
- */
- public function getOverview() {
- return $this->_data['overview'];
- }
- /**
- * Get the Collection's poster
- *
- * @return string
- */
- public function getPoster() {
- return $this->_data['poster_path'];
- }
- /**
- * Get the Collection's backdrop
- *
- * @return string
- */
- public function getBackdrop() {
- return $this->_data['backdrop_path'];
- }
- /**
- * Get the Collection's Movies
- *
- * @return Movie[]
- */
- public function getMovies() {
- $movies = array();
- foreach ($this->_data['parts'] as $data) {
- $movies[] = new Movie($data);
- }
- return $movies;
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
-}
diff --git a/src/includes/libs/TMDb/Company.php b/src/includes/libs/TMDb/Company.php
deleted file mode 100644
index 35f9e943..00000000
--- a/src/includes/libs/TMDb/Company.php
+++ /dev/null
@@ -1,108 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Company {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Company
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Company's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Company's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Company's description
- *
- * @return string
- */
- public function getDescription() {
- return $this->_data['description'];
- }
- /**
- * Get the Company's headquearters
- *
- * @return string
- */
- public function getHeadquarters() {
- return $this->_data['headquarters'];
- }
- /**
- * Get the Company's homepage
- *
- * @return string
- */
- public function getHomepage() {
- return $this->_data['homepage'];
- }
- /**
- * Get the Company's logo
- *
- * @return string
- */
- public function getLogo() {
- return $this->_data['logo_path'];
- }
- /**
- * Get the Company's parent company id
- *
- * @return int
- */
- public function getParentCompanyID() {
- return $this->_data['parent_company'];
- }
- /**
- * Get the Company's Movies
- *
- * @return Movie[]
- */
- public function getMovies() {
- $movies = array();
- foreach ($this->_data['movies']['results'] as $data) {
- $movies[] = new Movie($data);
- }
- return $movies;
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the Movie
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/Episode.php b/src/includes/libs/TMDb/Episode.php
deleted file mode 100644
index 27807aa4..00000000
--- a/src/includes/libs/TMDb/Episode.php
+++ /dev/null
@@ -1,121 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Episode {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of the Episode
- */
- public function __construct($data, $idTVShow = 0) {
- $this->_data = $data;
- $this->_data['tvshow_id'] = $idTVShow;
- }
- /**
- * Get the episode's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Episode's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Season's TVShow id
- *
- * @return int
- */
- public function getTVShowID() {
- return $this->_data['tvshow_id'];
- }
- /**
- * Get the Season's number
- *
- * @return int
- */
- public function getSeasonNumber() {
- return $this->_data['season_number'];
- }
- /**
- * Get the Episode's number
- *
- * @return string
- */
- public function getEpisodeNumber() {
- return $this->_data['episode_number'];
- }
- /**
- * Get the Episode's Overview
- *
- * @return string
- */
- public function getOverview() {
- return $this->_data['overview'];
- }
- /**
- * Get the Seasons's Still
- *
- * @return string
- */
- public function getStill() {
- return $this->_data['still_path'];
- }
- /**
- * Get the Season's AirDate
- *
- * @return string
- */
- public function getAirDate() {
- return $this->_data['air_date'];
- }
- /**
- * Get the Episode's vote average
- *
- * @return int
- */
- public function getVoteAverage() {
- return $this->_data['vote_average'];
- }
- /**
- * Get the Episode's vote count
- *
- * @return int
- */
- public function getVoteCount() {
- return $this->_data['vote_count'];
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the Episode
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/Genre.php b/src/includes/libs/TMDb/Genre.php
deleted file mode 100644
index 24a9d316..00000000
--- a/src/includes/libs/TMDb/Genre.php
+++ /dev/null
@@ -1,38 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Genre {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Collection
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Genre's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Genre's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
-}
diff --git a/src/includes/libs/TMDb/Movie.php b/src/includes/libs/TMDb/Movie.php
deleted file mode 100644
index 6c4fcf77..00000000
--- a/src/includes/libs/TMDb/Movie.php
+++ /dev/null
@@ -1,150 +0,0 @@
-Twitter
- * @version 0.1
- * @date 09/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Movie {
- public $_data;
- public $_tmdb;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of the Movie
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Movie's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Movie's title
- *
- * @return string
- */
- public function getTitle() {
- return $this->_data['title'];
- }
- /**
- * Get the Movie's tagline
- *
- * @return string
- */
- public function getTagline() {
- return $this->_data['tagline'];
- }
- /**
- * Get the Movie's Poster
- *
- * @return string
- */
- public function getPoster() {
- return $this->_data['poster_path'];
- }
- /**
- * Get the Movie's vote average
- *
- * @return int
- */
- public function getVoteAverage() {
- return $this->_data['vote_average'];
- }
- /**
- * Get the Movie's vote count
- *
- * @return int
- */
- public function getVoteCount() {
- return $this->_data['vote_count'];
- }
- /**
- * Get the Movie's trailers
- *
- * @return array
- */
- public function getTrailers() {
- return $this->_data['trailers'];
- }
- /**
- * Get the Movie's trailer
- *
- * @return string
- */
- public function getTrailer() {
- $trailers = $this->getTrailers();
- return $trailers['youtube'][0]['source'];
- }
- /**
- * Get the Movie's genres
- *
- * @return Genre[]
- */
- public function getGenres() {
- $genres = array();
- foreach ($this->_data['genres'] as $data) {
- $genres[] = new Genre($data);
- }
- return $genres;
- }
- /**
- * Get the Movie's reviews
- *
- * @return Review[]
- */
- public function getReviews() {
- $reviews = array();
- foreach ($this->_data['review']['result'] as $data) {
- $reviews[] = new Review($data);
- }
- return $reviews;
- }
- /**
- * Get the Movie's companies
- *
- * @return Company[]
- */
- public function getCompanies() {
- $companies = array();
- foreach ($this->_data['production_companies'] as $data) {
- $companies[] = new Company($data);
- }
- return $companies;
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Set an instance of the API
- *
- * @param TMDB $tmdb An instance of the api, necessary for the lazy load
- */
- public function setAPI($tmdb) {
- $this->_tmdb = $tmdb;
- }
- /**
- * Get the JSON representation of the Movie
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/Person.php b/src/includes/libs/TMDb/Person.php
deleted file mode 100644
index 4220ab36..00000000
--- a/src/includes/libs/TMDb/Person.php
+++ /dev/null
@@ -1,120 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Person {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of the Person
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Person's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Person's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Person's profile image
- *
- * @return string
- */
- public function getProfile() {
- return $this->_data['profile_path'];
- }
- /**
- * Get the Person's birthday
- *
- * @return string
- */
- public function getBirthday() {
- return $this->_data['birthday'];
- }
- /**
- * Get the Person's place of birth
- *
- * @return string
- */
- public function getPlaceOfBirth() {
- return $this->_data['place_of_birth'];
- }
- /**
- * Get the Person's imdb id
- *
- * @return string
- */
- public function getImbdID() {
- return $this->_data['imdb_id'];
- }
- /**
- * Get the Person's popularity
- *
- * @return int
- */
- public function getPopularity() {
- return $this->_data['popularity'];
- }
- /**
- * Get the Person's MovieRoles
- *
- * @return MovieRole[]
- */
- public function getMovieRoles() {
- $movieRoles = array();
- foreach ($this->_data['movie_credits']['cast'] as $data) {
- $movieRoles[] = new MovieRole($data, $this->getID());
- }
- return $movieRoles;
- }
- /**
- * Get the Person's TVShowRoles
- *
- * @return TVShowRole[]
- */
- public function getTVShowRoles() {
- $tvShowRole = array();
- foreach ($this->_data['tv_credits']['cast'] as $data) {
- $tvShowRole[] = new TVShowRole($data, $this->getID());
- }
- return $tvShowRole;
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the Episode
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/Review.php b/src/includes/libs/TMDb/Review.php
deleted file mode 100644
index 8b76637d..00000000
--- a/src/includes/libs/TMDb/Review.php
+++ /dev/null
@@ -1,72 +0,0 @@
-Twitter
- * @version 0.1
- * @date 31/03/2016
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Review {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Review
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the Review's id
- *
- * @return int
- **/
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Review's author
- *
- * @return string
- */
- public function getAuthor() {
- return $this->_data['author'];
- }
- /**
- * Get the Review's content
- *
- * @return string
- */
- public function getContent() {
- return $this->_data['content'];
- }
- /**
- * Get the Review's url
- *
- * @return string
- */
- public function getURL() {
- return $this->_data['url'];
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the Movie
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/Role.php b/src/includes/libs/TMDb/Role.php
deleted file mode 100644
index f5ccdb5b..00000000
--- a/src/includes/libs/TMDb/Role.php
+++ /dev/null
@@ -1,49 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Role {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Role
- */
- protected function __construct($data, $ipPerson) {
- $this->_data = $data;
- $this->_data['person_id'] = $ipPerson;
- }
- /**
- * Get the Role's character
- *
- * @return string
- */
- public function getCharacter() {
- return $this->_data['character'];
- }
- /**
- * Get the Movie's poster
- *
- * @return string
- */
- public function getPoster() {
- return $this->_data['poster_path'];
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
-}
diff --git a/src/includes/libs/TMDb/Season.php b/src/includes/libs/TMDb/Season.php
deleted file mode 100644
index 72a04c77..00000000
--- a/src/includes/libs/TMDb/Season.php
+++ /dev/null
@@ -1,119 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class Season {
- private $_data;
- private $_idTVShow;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of the Season
- */
- public function __construct($data, $idTVShow = 0) {
- $this->_data = $data;
- $this->_data['tvshow_id'] = $idTVShow;
- }
- /**
- * Get the Season's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the Season's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the Season's TVShow id
- *
- * @return int
- */
- public function getTVShowID() {
- return $this->_data['tvshow_id'];
- }
- /**
- * Get the Season's number
- *
- * @return int
- */
- public function getSeasonNumber() {
- return $this->_data['season_number'];
- }
- /**
- * Get the Season's number of episodes
- *
- * @return int
- */
- public function getNumEpisodes() {
- return count($this->_data['episodes']);
- }
- /**
- * Get a Seasons's Episode
- *
- * @param int $numEpisode The episode number
- * @return int
- */
- public function getEpisode($numEpisode) {
- return new Episode($this->_data['episodes'][$numEpisode]);
- }
- /**
- * Get the Season's Episodes
- *
- * @return Episode[]
- */
- public function getEpisodes() {
- $episodes = array();
- foreach ($this->_data['episodes'] as $data) {
- $episodes[] = new Episode($data, $this->getTVShowID());
- }
- return $episodes;
- }
- /**
- * Get the Seasons's Poster
- *
- * @return string
- */
- public function getPoster() {
- return $this->_data['poster_path'];
- }
- /**
- * Get the Season's AirDate
- *
- * @return string
- */
- public function getAirDate() {
- return $this->_data['air_date'];
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the Season
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/TVShow.php b/src/includes/libs/TMDb/TVShow.php
deleted file mode 100644
index 6a305e3d..00000000
--- a/src/includes/libs/TMDb/TVShow.php
+++ /dev/null
@@ -1,155 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class TVShow {
- private $_data;
- /**
- * Construct Class
- *
- * @param array $data An array with the data of the TVShow
- */
- public function __construct($data) {
- $this->_data = $data;
- }
- /**
- * Get the TVShow's id
- *
- * @return int
- */
- public function getID() {
- return $this->_data['id'];
- }
- /**
- * Get the TVShow's name
- *
- * @return string
- */
- public function getName() {
- return $this->_data['name'];
- }
- /**
- * Get the TVShow's original name
- *
- * @return string
- */
- public function getOriginalName() {
- return $this->_data['original_name'];
- }
- /**
- * Get the TVShow's number of seasons
- *
- * @return int
- */
- public function getNumSeasons() {
- return $this->_data['number_of_seasons'];
- }
- /**
- * Get the TVShow's number of episodes
- *
- * @return int
- */
- public function getNumEpisodes() {
- return $this->_data['number_of_episodes'];
- }
- /**
- * Get a TVShow's season
- *
- * @param int $numSeason The season number
- * @return int
- */
- public function getSeason($numSeason) {
- foreach ($this->_data['seasons'] as $season) {
- if ($season['season_number'] == $numSeason) {
- $data = $season;
- break;
- }
- }
- return new Season($data);
- }
- /**
- * Get the TvShow's seasons
- *
- * @return Season[]
- */
- public function getSeasons() {
- $seasons = array();
- foreach ($this->_data['seasons'] as $data) {
- $seasons[] = new Season($data, $this->getID());
- }
- return $seasons;
- }
- /**
- * Get the TVShow's Poster
- *
- * @return string
- */
- public function getPoster() {
- return $this->_data['poster_path'];
- }
- /**
- * Get the TVShow's Backdrop
- *
- * @return string
- */
- public function getBackdrop() {
- return $this->_data['backdrop_path'];
- }
- /**
- * Get the TVShow's Overview
- *
- * @return string
- */
- public function getOverview() {
- return $this->_data['overview'];
- }
- /**
- * Get the TVShow's vote average
- *
- * @return int
- */
- public function getVoteAverage() {
- return $this->_data['vote_average'];
- }
- /**
- * Get the TVShow's vote count
- *
- * @return int
- */
- public function getVoteCount() {
- return $this->_data['vote_count'];
- }
- /**
- * Get if the TVShow is in production
- *
- * @return boolean
- */
- public function getInProduction() {
- return $this->_data['in_production'];
- }
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
- /**
- * Get the JSON representation of the TVShow
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/config/APIConfiguration.php b/src/includes/libs/TMDb/config/APIConfiguration.php
deleted file mode 100644
index 5bda6837..00000000
--- a/src/includes/libs/TMDb/config/APIConfiguration.php
+++ /dev/null
@@ -1,106 +0,0 @@
-Twitter
- * @version 0.1
- * @date 20/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class APIConfiguration {
- private $_data;
-
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a Configuration
- */
- public function __construct($data) {
- $this->_data = $data;
- }
-
- /**
- * Get the Configuration's base URL for images
- *
- * @return string
- */
- public function getImageBaseURL() {
- return $this->_data['images']['base_url'];
- }
-
- /**
- * Get the Configuration's secure base URL for images
- *
- * @return string
- */
- public function getSecureImageBaseURL() {
- return $this->_data['images']['secure_base_url'];
- }
-
- /**
- * Get the Configuration's list of sizes for backdrops
- *
- * @return string[]
- */
- public function getBackdropSizes() {
- return $this->_data['images']['backdrop_sizes'];
- }
-
- /**
- * Get the Configuration's list of sizes for logos
- *
- * @return string[]
- */
- public function getLogoSizes() {
- return $this->_data['images']['logo_sizes'];
- }
-
- /**
- * Get the Configuration's list of sizes for posters
- *
- * @return string[]
- */
- public function getPosterSizes() {
- return $this->_data['images']['poster_sizes'];
- }
-
- /**
- * Get the Configuration's list of sizes for profiles
- *
- * @return string[]
- */
- public function getProfileSizes() {
- return $this->_data['images']['profile_sizes'];
- }
-
- /**
- * Get the Configuration's list of sizes for stills
- *
- * @return string[]
- */
- public function getStillSizes() {
- return $this->_data['images']['still_sizes'];
- }
-
- /**
- * Get Generic.
- * Get a item of the array, you should not get used to use this, better use specific get's.
- *
- * @param string $item The item of the $data array you want
- * @return array
- */
- public function get($item = '') {
- return empty($item) ? $this->_data : $this->_data[$item];
- }
-
- /**
- * Get the JSON representation of the Configuration
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/config/config.php b/src/includes/libs/TMDb/config/config.php
deleted file mode 100644
index 47a543dd..00000000
--- a/src/includes/libs/TMDb/config/config.php
+++ /dev/null
@@ -1,34 +0,0 @@
- array('trailers', 'images', 'credits', 'translations', 'reviews'),
- 'all' => array('account_states', 'alternative_titles', 'credits', 'images', 'keywords', 'release_dates', 'videos', 'translations', 'similar', 'reviews', 'lists', 'changes', 'rating')
-);
-$cnf['appender']['tvshow'] = array(
- 'default' => array('trailers', 'images', 'credits', 'translations', 'keywords'),
- 'all' => array('account_states', 'alternative_titles', 'changes', 'content_rating', 'credits', 'external_ids', 'images', 'keywords', 'rating', 'similar', 'translations', 'videos')
-);
-$cnf['appender']['season'] = array(
- 'default' => array('trailers', 'images', 'credits', 'translations'),
- 'all' => array('changes', 'account_states', 'credits', 'external_ids', 'images', 'videos')
-);
-$cnf['appender']['episode'] = array(
- 'default' => array('trailers', 'images', 'credits', 'translations'),
- 'all' => array('changes', 'account_states', 'credits', 'external_ids', 'images', 'rating', 'videos')
-);
-$cnf['appender']['person'] = array(
- 'default' => array('movie_credits', 'tv_credits', 'images'),
- 'all' => array('movie_credits', 'tv_credits', 'combined_credits', 'external_ids', 'images', 'tagged_images', 'changes')
-);
-$cnf['appender']['collection'] = array(
- 'default' => array('images'),
- 'all' => array('images')
-);
-$cnf['appender']['company'] = array(
- 'default' => array('movies'),
- 'all' => array('movies')
-);
diff --git a/src/includes/libs/TMDb/roles/MovieRole.php b/src/includes/libs/TMDb/roles/MovieRole.php
deleted file mode 100644
index a4fa5d5e..00000000
--- a/src/includes/libs/TMDb/roles/MovieRole.php
+++ /dev/null
@@ -1,69 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class MovieRole extends Role {
- private $_data;
-
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a MovieRole
- */
- public function __construct($data, $idPerson) {
- $this->_data = $data;
- parent::__construct($data, $idPerson);
- }
-
- /**
- * Get the Movie's title of the role
- *
- * @return string
- */
- public function getMovieTitle() {
- return $this->_data['title'];
- }
-
- /**
- * Get the Movie's id
- *
- * @return int
- */
- public function getMovieID() {
- return $this->_data['id'];
- }
-
- /**
- * Get the Movie's original title of the role
- *
- * @return string
- */
- public function getMovieOriginalTitle() {
- return $this->_data['original_title'];
- }
-
- /**
- * Get the Movie's release date of the role
- *
- * @return string
- */
- public function getMovieReleaseDate() {
- return $this->_data['release_date'];
- }
-
- /**
- * Get the JSON representation of the Episode
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/TMDb/roles/TVShowRole.php b/src/includes/libs/TMDb/roles/TVShowRole.php
deleted file mode 100644
index 447aecca..00000000
--- a/src/includes/libs/TMDb/roles/TVShowRole.php
+++ /dev/null
@@ -1,69 +0,0 @@
-Twitter
- * @version 0.1
- * @date 11/01/2015
- * @link https://github.com/Alvaroctal/TMDB-PHP-API
- * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- */
-class TVShowRole extends Role {
- private $_data;
-
- /**
- * Construct Class
- *
- * @param array $data An array with the data of a TVShowRole
- */
- public function __construct($data, $idPerson) {
- $this->_data = $data;
- parent::__construct($data, $idPerson);
- }
-
- /**
- * Get the TVShow's title of the role
- *
- * @return string
- */
- public function getTVShowName() {
- return $this->_data['name'];
- }
-
- /**
- * Get the TVShow's id
- *
- * @return int
- */
- public function getTVShowID() {
- return $this->_data['id'];
- }
-
- /**
- * Get the TVShow's original title of the role
- *
- * @return string
- */
- public function getTVShowOriginalTitle() {
- return $this->_data['original_name'];
- }
-
- /**
- * Get the TVShow's release date of the role
- *
- * @return string
- */
- public function getTVShowFirstAirDate() {
- return $this->_data['first_air_date'];
- }
-
- /**
- * Get the JSON representation of the Episode
- *
- * @return string
- */
- public function getJSON() {
- return json_encode($this->_data, JSON_PRETTY_PRINT);
- }
-}
diff --git a/src/includes/libs/Translator.php b/src/includes/libs/Translator.php
deleted file mode 100644
index 0884335f..00000000
--- a/src/includes/libs/Translator.php
+++ /dev/null
@@ -1,181 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @version 1.0.0
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- *
- * A PHP class created specifically for the XC_VM project to provide multilingual support.
- * Features automatic translation key generation, INI file management, language switching,
- * and missing key auto-creation with file locking for concurrent access.
- */
-
-class Translator {
- /** @var array
Currently loaded translations */
- private static array $translations = [];
-
- /** @var string Current language */
- private static string $currentLang = 'en';
-
- /** @var string Path to translations folder (with trailing slash) */
- private static string $langsDir = __DIR__ . '/lang/';
-
- /** @var array Cache of available languages */
- private static array $availableLanguages = [];
-
- /**
- * Initialize translator
- *
- * @param string|null $langsDir Path to .ini files folder (e.g., /var/www/lang/)
- */
- public static function init(?string $langsDir = null): void {
- if ($langsDir !== null) {
- self::$langsDir = rtrim($langsDir, '/') . '/';
- }
-
- // Get and cache list of languages
- self::$availableLanguages = self::scanAvailableLanguages();
-
- // Detect user language
- $requestedLang = $_COOKIE['lang'] ?? 'en';
- self::$currentLang = in_array($requestedLang, self::$availableLanguages)
- ? $requestedLang
- : 'en';
-
- self::loadLanguage(self::$currentLang);
- }
-
- /**
- * Change language at runtime + update cookie
- */
- public static function setLanguage(string $lang): bool {
- if (!in_array($lang, self::$availableLanguages)) {
- return false;
- }
-
- self::$currentLang = $lang;
- self::loadLanguage($lang);
-
- // Cookie for one year
- setcookie('lang', $lang, time() + 365 * 24 * 3600, '/');
-
- return true;
- }
-
- /**
- * Get translation by key
- * If key doesn't exist — it will be automatically added to all language files
- */
- public static function get(string $key, array $replace = []): string {
- $text = self::$translations[$key] ?? null;
-
- if ($text === null) {
- self::addMissingKeyToAllLanguages($key);
- $text = $key; // fallback to the key itself
- // Update current loaded array so subsequent calls see the key immediately
- self::$translations[$key] = $key;
- }
-
- return !empty($replace) ? strtr($text, $replace) : $text;
- }
-
- /**
- * Current language
- */
- public static function current(): string {
- return self::$currentLang;
- }
-
- /**
- * All available languages
- */
- public static function available(): array {
- return self::$availableLanguages;
- }
-
- // ═════════════════════════════════════════════════════════════════
- // Internal methods
- // ═════════════════════════════════════════════════════════════════
-
- private static function scanAvailableLanguages(): array {
- $languages = [];
- $files = glob(self::$langsDir . '*.ini');
-
- foreach ($files as $file) {
- if (is_file($file) && is_readable($file)) {
- $code = pathinfo($file, PATHINFO_FILENAME);
- // Optionally filter by valid language codes if needed
- $languages[] = $code;
- }
- }
-
- // If nothing found at all — guarantee at least en
- $languages = array_unique($languages);
- if (empty($languages)) {
- $languages = ['en'];
- }
-
- return $languages;
- }
-
- private static function loadLanguage(string $lang): void {
- $file = self::$langsDir . $lang . '.ini';
-
- // If current language file is not readable — fallback to en
- if (!is_readable($file)) {
- $file = self::$langsDir . 'en.ini';
- }
-
- $data = parse_ini_file($file, false, INI_SCANNER_RAW);
- self::$translations = ($data !== false) ? $data : [];
- }
-
- private static function addMissingKeyToAllLanguages(string $key): void {
- $lineToAdd = "\n{$key} = \"{$key}\"\n";
-
- foreach (self::$availableLanguages as $lang) {
- $file = self::$langsDir . $lang . '.ini';
-
- // If file doesn't exist — create empty one
- if (!file_exists($file)) {
- file_put_contents($file, "; {$lang} language file\n");
- }
-
- // Check if key already exists
- $content = file_get_contents($file);
- if (str_contains($content, "\n{$key} =") || str_contains($content, "\r{$key} =")) {
- continue; // key already exists
- }
-
- // Safe write with locking
- $fp = fopen($file, 'a');
- if ($fp && flock($fp, LOCK_EX)) {
- fwrite($fp, $lineToAdd);
- flock($fp, LOCK_UN);
- fclose($fp);
- }
- }
- }
-}
-
-
-
-
-// // At the beginning of the application (once)
-// Translator::init('/path/to/your/lang/'); // or just Translator::init(); if lang folder is nearby
-
-// // Anywhere in the code
-// echo Translator::get('welcome_title');
-// echo Translator::get('users_online', [':count' => 153]);
-
-// // Change language
-// Translator::setLanguage('de');
-
-// // Utility methods
-// echo Translator::current(); // → "de"
-// print_r(Translator::available()); // → ['en', 'ru', 'de', 'fr', ...]
\ No newline at end of file
diff --git a/src/includes/libs/XmlStringStreamer.php b/src/includes/libs/XmlStringStreamer.php
deleted file mode 100644
index e88261c8..00000000
--- a/src/includes/libs/XmlStringStreamer.php
+++ /dev/null
@@ -1,629 +0,0 @@
-parser = $parser;
- $this->stream = $stream;
- }
-
- /**
- * Convenience method for creating a StringWalker parser with a File stream
- * @param string|resource $file File path or handle
- * @param array $options Parser configuration
- * @return XmlStringStreamer A streamer ready for use
- */
- public static function createStringWalkerParser($file, $options = array()) {
- $stream = new File($file, 16384);
- $parser = new StringWalker($options);
-
- return new XmlStringStreamer($parser, $stream);
- }
-
- /**
- * Convenience method for creating a UniqueNode parser with a File stream
- * @param string|resource $file File path or handle
- * @param array $options Parser configuration
- * @return XmlStringStreamer A streamer ready for use
- */
- public static function createUniqueNodeParser($file, $options = array()) {
- $stream = new File($file, 16384);
- $parser = new UniqueNode($options);
-
- return new XmlStringStreamer($parser, $stream);
- }
-
- /**
- * Gets the next node from the parser
- * @return bool|string The xml string or false
- */
- public function getNode() {
- return $this->parser->getNodeFrom($this->stream);
- }
-}
-
-/**
- * Interface describing a parser
- */
-interface ParserInterface {
- /**
- * Parser contructor
- * @param array $options An options array decided by the parser implementation
- */
- public function __construct(array $options);
-
- /**
- * Tries to retrieve the next node or returns false
- * @param StreamInterface $stream The stream to use
- * @return string|bool The next xml node or false if one could not be retrieved
- */
- public function getNodeFrom(StreamInterface $stream);
-
- /**
- * Get the extracted container XML, if called before the whole stream is parsed, the XML returned can be invalid due to missing closing tags
- * @return string XML string
- */
- public function getExtractedContainer();
-}
-
-/**
- * Interface describing a stream provider
- */
-interface StreamInterface {
- /**
- * Gets the next chunk form the stream if one is available
- * @return bool|string The next chunk if available, or false if not available
- */
- public function getChunk();
-
- /**
- * Is the stream seekable?
- * @return bool
- */
- public function isSeekable();
-
- /**
- * Rewind the stream
- * @return void
- * @throws Exception if the stream isn't seekable
- */
- public function rewind();
-}
-
-/**
- * The string walker parser builds the XML nodes by fetching one element at a time until a certain depth is re-reached
- */
-class StringWalker implements ParserInterface {
- /**
- * Holds the parser configuration
- * @var array
- */
- protected $options;
- /**
- * Is this the first run?
- * @var boolean
- */
- protected $firstRun = true;
- /**
- * What depth are we currently at?
- * @var integer
- */
- protected $depth = 0;
- /**
- * The latest chunk from the stream
- * @var string
- */
- protected $chunk;
- /**
- * Last XML node in the making, used for anti-freeze detection
- * @var null|string
- */
- protected $lastChunk;
- /**
- * XML node in the making
- * @var null|string
- */
- protected $shaved;
- /**
- * Whether to capture or not
- * @var boolean
- */
- protected $capture = false;
- /**
- * If extractContainer is true, this will grow with the XML captured before and after the specified capture depth
- * @var string
- */
- protected $containerXml = '';
-
- /**
- * Parser contructor
- * @param array $options An options array
- */
- public function __construct(array $options = array()) {
- $this->options = array_merge(array(
- 'captureDepth' => 2,
- 'expectGT' => false,
- 'tags' => array(
- array('', '?>', 0),
- array('', 0),
- array('', 0),
- array('', 0),
- array('', '>', -1),
- array('<', '/>', 0),
- array('<', '>', 1)
- ),
- 'tagsWithAllowedGT' => array(
- array(''),
- array('')
- ),
- 'extractContainer' => false
- ), $options);
- }
-
- /**
- * Shaves off the next element from the chunk
- * @return string[]|bool Either a shaved off element array(0 => Captured element, 1 => Data from last shaving point up to and including captured element) or false if one could not be obtained
- */
- protected function shave() {
- preg_match('/<[^>]+>/', $this->chunk, $matches, PREG_OFFSET_CAPTURE);
-
- if (isset($matches[0]) && isset($matches[0][0]) && isset($matches[0][1])) {
- list($captured, $offset) = $matches[0];
-
- if ($this->options['expectGT']) {
- foreach ($this->options['tagsWithAllowedGT'] as $tag) {
- list($opening, $closing) = $tag;
-
- if (substr($captured, 0, strlen($opening)) === $opening) {
- if (substr($captured, -1 * strlen($closing)) !== $closing) {
- $position = strpos($this->chunk, $closing);
-
- if ($position === false) {
- return false;
- }
-
- $captured = substr($this->chunk, $offset, ($position + strlen($closing)) - $offset);
- }
- }
- }
- }
-
- $data = substr($this->chunk, 0, $offset);
- $this->chunk = substr($this->chunk, $offset + strlen($captured));
-
- return array($captured, $data . $captured);
- }
-
- return false;
- }
-
- /**
- * Extract XML compatible tag head and tail
- * @param string $element XML element
- * @return string[] 0 => Opening tag, 1 => Closing tag
- */
- protected function getEdges($element) {
- foreach ($this->options['tags'] as $tag) {
- list($opening, $closing, $depth) = $tag;
-
- if ((substr($element, 0, strlen($opening)) === $opening) && (substr($element, -1 * strlen($closing)) === $closing)) {
- return $tag;
- }
- }
- }
-
- /**
- * The shave method must be able to request more data even though there isn't any more to fetch from the stream, this method wraps the getChunk call so that it returns true as long as there is XML data left
- * @param StreamInterface $stream The stream to read from
- * @return bool Returns whether there is more XML data or not
- */
- protected function prepareChunk(StreamInterface $stream) {
- if (!$this->firstRun && is_null($this->shaved)) {
- $this->shaved = '';
-
- return true;
- } elseif (is_null($this->shaved)) {
- $this->shaved = '';
- }
-
- $newChunk = $stream->getChunk();
-
- if ($newChunk !== false) {
- $this->chunk .= $newChunk;
-
- return true;
- } elseif ((trim($this->chunk) !== '') && ($this->chunk !== $this->lastChunk)) {
- $this->lastChunk = $this->chunk;
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Get the extracted container XML, if called before the whole stream is parsed, the XML returned will most likely be invalid due to missing closing tags
- * @return string XML string
- * @throws Exception if the extractContainer option isn't true
- */
- public function getExtractedContainer() {
- if (!$this->options['extractContainer']) {
- throw new Exception('This method requires the \'extractContainer\' option to be true');
- }
-
- return $this->containerXml;
- }
-
- /**
- * Tries to retrieve the next node or returns false
- * @param StreamInterface $stream The stream to use
- * @return string|bool The next xml node or false if one could not be retrieved
- */
- public function getNodeFrom(StreamInterface $stream) {
- while ($this->prepareChunk($stream)) {
- $this->firstRun = false;
-
- while ($shaved = $this->shave()) {
- list($element, $data) = $shaved;
- list($opening, $closing, $depth) = $this->getEdges($element);
- $this->depth += $depth;
- $flush = false;
- $captureOnce = false;
-
- if (($this->depth === $this->options['captureDepth']) && (0 < $depth)) {
- $this->capture = true;
- } elseif (($this->depth === $this->options['captureDepth'] - 1) && ($depth < 0)) {
- $flush = true;
- $this->capture = false;
- $this->shaved .= $data;
- } elseif ($this->options['extractContainer'] && ($this->depth < $this->options['captureDepth'])) {
- $this->containerXml .= $element;
- } elseif (($depth === 0) && (($this->depth + 1) === $this->options['captureDepth'])) {
- $captureOnce = true;
- $flush = true;
- }
-
- if ($this->capture || $captureOnce) {
- $this->shaved .= $data;
- }
-
- if ($flush) {
- $flush = $this->shaved;
- $this->shaved = null;
-
- return $flush;
- }
- }
- }
-
- return false;
- }
-}
-
-/**
- * The unique node parser starts at a given element name and flushes when its corresponding closing tag is found
- */
-class UniqueNode implements ParserInterface {
- public const FIND_OPENING_TAG_ACTION = 0;
- public const FIND_CLOSING_TAG_ACTION = 1;
-
- /**
- * Current working XML blob
- * @var string
- */
- private $workingBlob = '';
- /**
- * The flushed node
- * @var string
- */
- private $flushed = '';
- /**
- * Start position of the given element in the workingBlob
- * @var integer
- */
- private $startPos = 0;
- /**
- * Records how far we've searched in the XML blob so far
- * @var integer
- */
- private $hasSearchedUntilPos = -1;
- /**
- * Next action to perform
- * @var integer
- */
- private $nextAction = 0;
- /**
- * Indicates short closing tag
- * @var bool
- */
- private $shortClosedTagNow = false;
- /**
- * If extractContainer is true, this will grow with the XML captured before and after the specified capture depth
- * @var string
- */
- protected $containerXml = '';
- /**
- * Whether we're found our first capture target or not
- * @var bool
- */
- protected $preCapture = true;
-
- /**
- * Parser constructor
- * @param array $options An options array
- * @throws Exception if the required option uniqueNode isn't set
- */
- public function __construct(array $options = array()) {
- $this->options = array_merge(array('extractContainer' => false), $options);
-
- if (!isset($this->options['uniqueNode'])) {
- throw new Exception('Required option \'uniqueNode\' not set');
- }
- }
-
- /**
- * Search the blob for our unique node's opening tag
- * @return bool|int Either returns the char position of the opening tag or false
- */
- protected function getOpeningTagPos() {
- $startPositionInBlob = false;
-
- if (preg_match('/<' . preg_quote($this->options['uniqueNode']) . '(>| )/', $this->workingBlob, $matches, PREG_OFFSET_CAPTURE) === 1) {
- $startPositionInBlob = $matches[0][1];
- }
-
- if ($startPositionInBlob === false) {
- $this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
- }
-
- return $startPositionInBlob;
- }
-
- /**
- * Search short closing tag in $workingBlob before
- *
- * @param string $workingBlob
- * @param int $len
- * @return bool|int Either returns the char position of the short closing tag or false
- */
- private function checkShortClosingTag($workingBlob, $len) {
- $resultEndPositionInBlob = false;
-
- while ($len = strpos($workingBlob, '/>', $len + 1)) {
- $subBlob = substr($workingBlob, $this->startPos, ($len + strlen('/>')) - $this->startPos);
- $cntOpen = substr_count($subBlob, '<');
- $cntClose = substr_count($subBlob, '/>');
-
- if (($cntOpen === $cntClose) && ($cntOpen === 1)) {
- $resultEndPositionInBlob = $len + strlen('/>');
-
- break;
- }
- }
-
- return $resultEndPositionInBlob;
- }
-
- /**
- * Search the blob for our unique node's closing tag
- * @return bool|int Either returns the char position of the closing tag or false
- */
- protected function getClosingTagPos() {
- $endPositionInBlob = strpos($this->workingBlob, '' . $this->options['uniqueNode'] . '>');
-
- if ($endPositionInBlob === false) {
- if (isset($this->options['checkShortClosing']) && ($this->options['checkShortClosing'] === true)) {
- $endPositionInBlob = $this->checkShortClosingTag($this->workingBlob, $this->startPos);
- }
-
- if ($endPositionInBlob === false) {
- $this->hasSearchedUntilPos = strlen($this->workingBlob) - 1;
- } else {
- $this->shortClosedTagNow = true;
- }
- } elseif (isset($this->options['checkShortClosing']) && ($this->options['checkShortClosing'] === true)) {
- $tmpEndPositionInBlob = $this->checkShortClosingTag(substr($this->workingBlob, 0, $endPositionInBlob), $this->startPos);
-
- if ($tmpEndPositionInBlob !== false) {
- $this->shortClosedTagNow = true;
- $endPositionInBlob = $tmpEndPositionInBlob;
- }
- }
-
- return $endPositionInBlob;
- }
-
- /**
- * Set the start position in the workingBlob from where we should start reading when the closing tag is found
- * @param int $startPositionInBlob Position of starting tag
- */
- protected function startSalvaging($startPositionInBlob) {
- $this->startPos = $startPositionInBlob;
- }
-
- /**
- * Cut everything from the start position to the end position in the workingBlob (+ tag length) and flush it out for later return in getNodeFrom
- * @param int $endPositionInBlob Position of the closing tag
- */
- protected function flush($endPositionInBlob) {
- $endTagLen = ($this->shortClosedTagNow ? 0 : strlen('' . $this->options['uniqueNode'] . '>'));
- $realEndPosition = $endPositionInBlob + $endTagLen;
- $this->flushed = substr($this->workingBlob, $this->startPos, $realEndPosition - $this->startPos);
- $this->workingBlob = substr($this->workingBlob, $realEndPosition);
- $this->hasSearchedUntilPos = 0;
- $this->shortClosedTagNow = false;
- }
-
- /**
- * Decides whether we're to fetch more chunks from the stream or keep working with what we have.
- * @param StreamInterface $stream The stream provider
- * @return bool Keep working?
- */
- protected function prepareChunk(StreamInterface $stream) {
- if ((-1 < $this->hasSearchedUntilPos) && ($this->hasSearchedUntilPos < (strlen($this->workingBlob) - 1))) {
- return true;
- }
-
- $chunk = $stream->getChunk();
-
- if ($chunk === false) {
- if (($this->hasSearchedUntilPos === -1) && (0 < strlen($this->workingBlob))) {
- return true;
- }
-
- return false;
- } else {
- if (($this->nextAction === 0) && !$this->options['extractContainer']) {
- $this->workingBlob = substr($this->workingBlob, -1 * strlen('<' . $this->options['uniqueNode'] . '>')) . $chunk;
- } else {
- $this->workingBlob .= $chunk;
- }
-
- return true;
- }
- }
-
- /**
- * Tries to retrieve the next node or returns false
- * @param StreamInterface $stream The stream to use
- * @return string|bool The next xml node or false if one could not be retrieved
- */
- public function getNodeFrom(StreamInterface $stream) {
- while ($this->prepareChunk($stream)) {
- if ($this->nextAction === 0) {
- $positionInBlob = $this->getOpeningTagPos();
-
- if ($positionInBlob !== false) {
- if ($this->options['extractContainer'] && $this->preCapture) {
- $this->containerXml .= substr($this->workingBlob, 0, $positionInBlob);
- $this->preCapture = false;
- }
-
- $this->startSalvaging($positionInBlob);
- $this->nextAction = 1;
- }
- }
-
- if ($this->nextAction === 1) {
- $positionInBlob = $this->getClosingTagPos();
-
- if ($positionInBlob !== false) {
- $this->flush($positionInBlob);
- $this->nextAction = 0;
- $flushed = $this->flushed;
- $this->flushed = '';
-
- return $flushed;
- }
- }
- }
-
- if ($this->options['extractContainer']) {
- $this->containerXml .= $this->workingBlob;
- }
-
- return false;
- }
-
- /**
- * Get the extracted container XML, if called before the whole stream is parsed, the XML returned can be invalid due to missing closing tags
- * @return string XML string
- * @throws Exception if the extractContainer option isn't true
- */
- public function getExtractedContainer() {
- if (!$this->options['extractContainer']) {
- throw new Exception('This method requires the \'extractContainer\' option to be true');
- }
-
- return $this->containerXml;
- }
-}
-
-class File implements StreamInterface {
- private $handle;
- private $readBytes = 0;
- private $chunkSize;
- private $chunkCallback;
-
- public function __construct($mixed, $chunkSize = 16384, $chunkCallback = null) {
- if (is_string($mixed)) {
- if (!file_exists($mixed)) {
- throw new Exception('File \'' . $mixed . '\' doesn\'t exist');
- }
-
- $this->handle = fopen($mixed, 'rb');
- $this->handle;
- } elseif (get_resource_type($mixed) == 'stream') {
- $this->handle = $mixed;
- } else {
- throw new Exception('First argument must be either a filename or a file handle');
- }
-
- if ($this->handle === false) {
- throw new Exception('Couldn\'t create file handle');
- }
-
- $this->chunkSize = $chunkSize;
- $this->chunkCallback = $chunkCallback;
- }
-
- public function __destruct() {
- if (is_resource($this->handle)) {
- fclose($this->handle);
- }
- }
-
- public function getChunk() {
- if (is_resource($this->handle) && !feof($this->handle)) {
- $buffer = fread($this->handle, $this->chunkSize);
- $this->readBytes += strlen($buffer);
-
- if (is_callable($this->chunkCallback)) {
- call_user_func_array($this->chunkCallback, array($buffer, $this->readBytes));
- }
-
- return $buffer;
- }
-
- return false;
- }
-
- public function isSeekable() {
- $meta = stream_get_meta_data($this->handle);
-
- return $meta['seekable'];
- }
-
- public function rewind() {
- if (!$this->isSeekable()) {
- throw new Exception('Attempted to rewind an unseekable stream');
- }
-
- $this->readBytes = 0;
- rewind($this->handle);
- }
-}
-
-class Stdin extends File {
- public function __construct($chunkSize = 1024, $chunkCallback = null) {
- parent::__construct(fopen('php://stdin', 'r'), $chunkSize, $chunkCallback);
- }
-}
diff --git a/src/includes/libs/iptables.php b/src/includes/libs/iptables.php
deleted file mode 100644
index 75a3710d..00000000
--- a/src/includes/libs/iptables.php
+++ /dev/null
@@ -1,774 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-class Chain {
- private $name;
- private $table;
- private $policy;
- private $rules = array();
-
- public function __construct($name, $table, $policy) {
- $this->name = $name;
- $this->policy = $policy;
- $this->table = $table;
- }
-
- public function insertRule(Rule $rule, $id) {
- $tmp = array_slice($this->rules, 0, $id - 1) + array('tmp' => $rule) + array_slice($this->rules, $id - 2);
- $this->rules = $tmp;
- $this->resetIndexes();
-
- return (new Command($this->table))->setOptions((string) $rule)->insertRule($this->getName(), $id);
- }
-
- public function appendRule(Rule $rule) {
- $nextId = count($this->rules) + 1;
- $this->rules[$nextId] = $rule;
- $rule->setNum($nextId);
-
- return (new Command($this->table))->setOptions((string) $rule)->appendRule($this->getName());
- }
-
- public function replaceRule(Rule $rule, $id) {
- $this->rules[$id] = $rule;
- $rule->setNum($id);
-
- return (new Command($this->table))->setOptions((string) $rule)->replaceRule($this->getName(), $id);
- }
-
- public function deleteRule($id) {
- unset($this->rules[$id]);
- $this->resetIndexes();
-
- return (new Command($this->table))->deleteRule($this->getName(), $id);
- }
-
- public function flush() {
- $this->rules = array();
-
- return (new Command($this->table))->flushChain($this->getName());
- }
-
- public function rename($newName) {
- $oldName = $this->name;
- $this->name = $newName;
-
- return (new Command($this->table))->renameChain($oldName, $newName);
- }
-
- private function resetIndexes() {
- $this->rules = array_combine(array_keys(array_fill(1, count($this->rules), null)), $this->rules);
-
- foreach ($this->rules as $index => $rule) {
- $rule->setNum($index);
- }
- }
-
- public function getRulesList() {
- return $this->rules;
- }
-
- public function getName() {
- return $this->name;
- }
-
- public function getPolicy() {
- return $this->policy;
- }
-}
-
-class Rule {
- public $num;
- public $target;
- public $protocol;
- public $source;
- public $destination;
- public $options = array();
-
- public function __construct($target, $protocol, $source = null, $destination = null, $options = array()) {
- $this->target = $target;
- $this->protocol = $protocol;
- $this->source = $source;
- $this->destination = $destination;
-
- if (is_array($options)) {
- $this->options = $options;
- } else {
- $this->parseOptions($options);
- }
- }
-
- public function getNum() {
- return $this->num;
- }
-
- public function setNum($num) {
- $this->num = $num;
- }
-
- private function parseOptions($options) {
- if (preg_match('/(?:(?(s|d)pt)s?:)(?!?)(?(\\d+):?(\\d+))/', $options, $parsed)) {
- $map = array('dpt' => '--destination-port', 'spt' => '--source-port');
- $excl = (!empty($parsed['exclude']) ? $parsed['exclude'] . ' ' : '');
- $this->options[$map[$parsed['direction']]] = $excl . $parsed['ports'];
- }
-
- if (preg_match_all('/MAC\\s(?[\\d:]+)/', $options, $parsed)) {
- for ($i = 0; $i < count($parsed['macaddress']); $i++) {
- $this->options['--match'][] = 'mac --mac-source ' . $parsed['macaddress'][$i];
- }
- }
-
- if (preg_match_all('/limit:\\savg\\s(?\\d+\\/(sec|min|hour|day))\\sburst\\s(?\\d+)/', $options, $parsed)) {
- for ($i = 0; $i < count($parsed['limit']); $i++) {
- $this->options['--match'][] = 'limit --limit ' . $parsed['limit'][$i] . ' --limit-burst ' . $parsed['burst'][$i];
- }
- }
- }
-
- public function __toString() {
- $cmd = '';
-
- if ('all' != $this->protocol) {
- $cmd .= ' --proto ' . $this->protocol;
- }
-
- if (!is_null($this->source) && ('0.0.0.0/0' != $this->source)) {
- $cmd .= ' --source ' . $this->source;
- }
-
- if (!is_null($this->destination) && ('0.0.0.0/0' != $this->destination)) {
- $cmd .= ' --destination ' . $this->destination;
- }
-
- foreach ($this->options as $k => $value) {
- if (is_scalar($value)) {
- $cmd .= ' ' . $k . ' ' . $value;
- } else {
- foreach ($value as $option) {
- $cmd .= ' ' . $k . ' ' . $option;
- }
- }
- }
-
- $cmd .= (!empty($this->target) ? ' --jump ' . $this->target : '');
-
- return $cmd;
- }
-}
-
-class IptablesService {
- private $tables;
-
- public function __construct() {
- }
-
- public function parseIptablesChains(Table $table) {
- $data = explode("\n", $table->getRaw());
- $patterns = array('chain' => '/(?:Chain\\s)' . "\r\n" . ' (?[^\\s]+)' . "\r\n" . ' (?:.*\\()' . "\r\n" . ' (?.*)' . "\r\n" . ' (?:\\).*)/x', 'rule' => '/(?\\d+)\\s+' . "\r\n" . ' (?\\w+)\\s+' . "\r\n" . ' (?\\w+)\\s+' . "\r\n" . ' (?[\\w-]+)\\s+' . "\r\n" . ' (?[0-9\\.\\/]+)\\s+' . "\r\n" . ' (?[0-9\\.\\/]+)\\s+' . "\r\n" . ' ?(?.*)/x');
-
- foreach ($data as $row) {
- if (preg_match($patterns['chain'], $row, $out)) {
- $chain = new Chain($out['chain'], $table->getName(), $out['policy']);
- $table->addChain($chain);
- $this->tables[$table->getName()] = $table;
- }
-
- if (isset($chain) && preg_match($patterns['rule'], $row, $out)) {
- $rule = new Rule($out['target'], $out['protocol'], $out['source'], $out['destination'], trim($out['options']));
- $rule->setNum($out['id']);
- $chain->insertRule($rule, $out['id']);
- }
- }
-
- return $table->getChainsList();
- }
-}
-
-class Command {
- private $options = array();
- private $rawOptions;
- private $tcpFlags = array('ACK', 'FIN', 'PSH', 'RST', 'SYN', 'URG', 'ALL', 'NONE');
- private $matchModules = array('limit', 'mac', 'state', 'mark', 'recent');
- private $cmd;
- private $table;
-
- public function __construct($table) {
- $this->table = $table;
- }
-
- public function appendRule($chainName) {
- $this->cmd = '-A ' . $chainName;
-
- return (string) $this;
- }
-
- public function deleteRule($chainName, $ruleNum) {
- $this->cmd = '-D ' . $chainName . ' ' . $ruleNum;
-
- return (string) $this;
- }
-
- public function replaceRule($chainName, $ruleNum) {
- $this->cmd = '-R ' . $chainName . ' ' . $ruleNum;
-
- return (string) $this;
- }
-
- public function insertRule($chainName, $ruleNum = 1) {
- $this->cmd = '-I ' . $chainName . ' ' . $ruleNum;
-
- return (string) $this;
- }
-
- public function flushChain($chainName) {
- $this->cmd = '-F ' . $chainName;
- $this->cleanOptions();
-
- return (string) $this;
- }
-
- public function createChain($chainName) {
- $this->cmd = '-N ' . $chainName;
-
- return (string) $this;
- }
-
- public function deleteChain($chainName) {
- $this->cmd = '-X ' . $chainName;
- $this->cleanOptions();
-
- return (string) $this;
- }
-
- public function renameChain($chainName, $newName) {
- $this->cmd = '-E ' . $chainName . ' ' . $newName;
- $this->cleanOptions();
-
- return (string) $this;
- }
-
- private function cleanOptions() {
- $this->options = array();
- $this->rawOptions = null;
- }
-
- public function setProtocol($protocol, $sourcePort = null, $destinationPort = null, $tcpFlags = null) {
- $this->options['--proto'] = $protocol;
-
- if (in_array($protocol, array('tcp', 'udp')) && !is_null($sourcePort)) {
- $this->options['--proto'] .= ' --source-port ' . $sourcePort;
- }
-
- if (in_array($protocol, array('tcp', 'udp')) && !is_null($destinationPort)) {
- $this->options['--proto'] .= ' --destination-port ' . $destinationPort;
- }
-
- if (('tcp' == $protocol) && is_array($tcpFlags)) {
- $diff = array_diff($tcpFlags, $this->tcpFlags);
-
- if (!empty($diff)) {
- throw new Exception('Unexpected tcp-flags: ' . implode($diff));
- }
-
- $this->options['--proto'] .= ' --tcp-flags ' . implode(',', $tcpFlags);
- }
-
- return $this;
- }
-
- public function setSource($value) {
- $this->options['--source'] = $value;
-
- return $this;
- }
-
- public function setDestination($value) {
- $this->options['--destination'] = $value;
-
- return $this;
- }
-
- public function setJump($jump, ?array $params = null) {
- $this->options['--jump'] = $jump;
-
- if (!empty($params)) {
- foreach ($params as $name => $value) {
- $this->options['--jump'] .= ' --' . $name . ' ' . $value;
- }
- }
-
- return $this;
- }
-
- public function setMatch($module, array $params) {
- if (!in_array($module, $this->matchModules)) {
- throw new Exception('Invalid module: ' . $module);
- }
-
- $match = $module;
-
- foreach ($params as $name => $value) {
- $key = '--' . $module . ($name != $module ? '-' . $name : '');
- $match .= ' ' . $key . ' ' . $value;
- }
-
- $this->options['--match'] = $match;
-
- return $this;
- }
-
- public function setInput($value) {
- $this->options['--in-interface'] = $value;
-
- return $this;
- }
-
- public function setOutput($value) {
- $this->options['--out-interface'] = $value;
-
- return $this;
- }
-
- public function setOptions($options) {
- $this->rawOptions = $options;
-
- return $this;
- }
-
- public function __toString() {
- $cmd = '';
-
- if (!is_null($this->cmd)) {
- $cmd .= 'iptables ';
- $cmd .= $this->cmd;
- $cmd .= ' -t ' . $this->table;
- }
-
- if (!is_null($this->rawOptions)) {
- return $cmd . ' ' . $this->rawOptions;
- }
-
- foreach ($this->options as $k => $value) {
- if (is_scalar($value)) {
- $cmd .= ' ' . $k . ' ' . $value;
- } else {
- foreach ($value as $option) {
- $cmd .= ' ' . $k . ' ' . $option;
- }
- }
- }
-
- return $cmd;
- }
-}
-
-class Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name;
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
-
-class TableFactory {
- public function build($name) {
- switch ($name) {
- case 'filter':
- return new FilterTable();
-
- case 'mangle':
- return new MangleTable();
-
- case 'nat':
- return new NatTable();
-
- case 'raw':
- return new RawTable();
-
- case 'security':
- return new SecurityTable();
- }
-
- throw new Exception('Not found!');
- }
-}
-
-class FilterTable extends Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name = 'filter';
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
-
-class MangleTable extends Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name = 'mangle';
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
-
-class NatTable extends Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name = 'nat';
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
-
-class RawTable extends Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name = 'raw';
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
-
-class SecurityTable extends Table {
- public const TABLE_RAW = 'raw';
- public const TABLE_FILTER = 'filter';
- public const TABLE_NAT = 'nat';
- public const TABLE_MANGLE = 'mangle';
- public const TABLE_SECURITY = 'security';
-
- protected $name = 'security';
- protected $raw;
- protected $chains = array();
-
- public function getRaw() {
- return $this->raw;
- }
-
- public function setRaw($raw) {
- $this->raw = $raw;
- }
-
- public function addChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- }
-
- public function createChain(Chain $chain) {
- $this->chains[$chain->getName()] = $chain;
- $rulesCounter = count($chain->getRulesList());
- $command = new Command($this->name);
-
- if (1 < $rulesCounter) {
- throw new Exception('Maximum number Rules on creation is 1.');
- } elseif (1 === $rulesCounter) {
- $command->setOptions((string) current($chain->getRulesList()));
- }
-
- return $command->createChain($chain->getName());
- }
-
- public function deleteChain($name) {
- $chain = $this->getChainByName($name);
- unset($this->chains[$name]);
-
- return (new Command($this->name))->deleteChain($chain->getName());
- }
-
- public function getChainsList() {
- return $this->chains;
- }
-
- public function getChainByName($name) {
- foreach ($this->chains as $chain) {
- if ($name === $chain->getName()) {
- return $chain;
- }
- }
-
- throw new Exception('Chain not found.');
- }
-
- public function getName() {
- return $this->name;
- }
-}
diff --git a/src/includes/libs/m3u.php b/src/includes/libs/m3u.php
deleted file mode 100644
index 58e321ba..00000000
--- a/src/includes/libs/m3u.php
+++ /dev/null
@@ -1,579 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-trait TagAttributesTrait {
- /**
- * @var array
- */
- private $attributes = array();
-
- /**
- * example string: tvg-ID="" tvg-name="MEDI 1 SAT" tvg-logo="" group-title="ARABIC".
- */
- public function initAttributes(string $attrString): void {
- $this->parseQuotedAttributes($attrString);
- $this->parseNotQuotedAttributes($attrString);
- }
-
- public function getAttributes(): array {
- return $this->attributes;
- }
-
- public function getAttribute(string $name): ?string {
- return $this->attributes[$name] ?? null;
- }
-
- public function hasAttribute(string $name): bool {
- return isset($this->attributes[$name]);
- }
-
- /**
- * @return $this
- */
- public function setAttributes(array $attributes): TagAttributesTrait {
- $this->attributes = $attributes;
-
- return $this;
- }
-
- /**
- * @return $this
- */
- public function setAttribute(string $name, string $value): TagAttributesTrait {
- $this->attributes[$name] = $value;
-
- return $this;
- }
-
- protected function getAttributesString(): string {
- $out = '';
-
- foreach ($this->getAttributes() as $name => $value) {
- $out .= $name . '="' . $value . '" ';
- }
-
- return rtrim($out);
- }
-
- private function parseQuotedAttributes(string $attrString): void {
- preg_match_all('/([a-zA-Z0-9\\-]+)="([^"]*)"/', $attrString, $matches, PREG_SET_ORDER);
-
- foreach ($matches as $match) {
- $this->setAttribute($match[1], $match[2]);
- }
- }
-
- private function parseNotQuotedAttributes(string $attrString): void {
- preg_match_all('/([a-zA-Z0-9\\-]+)=([^ "]+)/', $attrString, $matches, PREG_SET_ORDER);
-
- foreach ($matches as $match) {
- $this->setAttribute($match[1], $match[2]);
- }
- }
-}
-
-trait TagsManagerTrait {
- /**
- * @var array
- */
- private $tags = array();
-
- /**
- * Add tag.
- *
- * @param string $tag class name must be implement ExtTagInterface interface
- *
- * @return $this
- */
- public function addTag(string $tag): TagsManagerTrait {
- if (!in_array('ExtTagInterface', class_implements($tag), true)) {
- throw new Exception(sprintf('The class %s must be implement interface %s', $tag, 'ExtTagInterface'));
- }
-
- $this->tags[] = $tag;
-
- return $this;
- }
-
- /**
- * Add default tags (EXTINF, EXTTV, EXTLOGO).
- *
- * @return $this
- */
- public function addDefaultTags(): TagsManagerTrait {
- $this->addTag('ExtInf');
- $this->addTag('ExtTv');
- $this->addTag('ExtLogo');
-
- return $this;
- }
-
- /**
- * Remove all previously defined tags.
- *
- * @return $this
- */
- public function clearTags(): TagsManagerTrait {
- $this->tags = array();
-
- return $this;
- }
-
- /**
- * Get all active tags.
- *
- * @return string[]
- */
- protected function getTags(): array {
- return $this->tags;
- }
-}
-
-class M3uEntry {
- /**
- * @var string
- */
- protected $lineDelimiter = "\n";
- /**
- * @var ExtTagInterface[]
- */
- private $extTags = array();
- /**
- * @var null|string
- */
- private $path;
-
- public function __toString(): string {
- $out = '';
-
- foreach ($this->getExtTags() as $extTag) {
- $out .= $extTag . $this->lineDelimiter;
- }
-
- $out .= $this->getPath();
-
- return rtrim($out);
- }
-
- /**
- * @return ExtTagInterface[]
- */
- public function getExtTags(): array {
- return $this->extTags;
- }
-
- /**
- * @return $this
- */
- public function addExtTag(ExtTagInterface $extTag): M3uEntry {
- $this->extTags[] = $extTag;
-
- return $this;
- }
-
- /**
- * Remove all previously defined tags.
- *
- * @return $this
- */
- public function clearExtTags(): M3uEntry {
- $this->extTags = array();
-
- return $this;
- }
-
- public function getPath(): string {
- return $this->path;
- }
-
- /**
- * @return $this
- */
- public function setPath(string $path): M3uEntry {
- $this->path = $path;
-
- return $this;
- }
-}
-
-interface ExtTagInterface {
- public function __construct(?string $lineStr);
-
- public function __toString(): string;
-
- public static function isMatch(string $lineStr): bool;
-}
-
-class M3uParser {
- use TagsManagerTrait;
-
- /**
- * Parse m3u file.
- */
- public function parseFile(string $file): M3uData {
- $str = @file_get_contents($file);
-
- if (false === $str) {
- throw new Exception('Can\'t read file.');
- }
-
- return $this->parse($str);
- }
-
- /**
- * Parse m3u string.
- */
- public function parse(string $str): M3uData {
- $this->removeBom($str);
- $data = $this->createM3uData();
- $lines = explode("\n", $str);
- $l = count($lines);
-
- for ($i = 0; $i < $l; ++$i) {
- $lineStr = trim($lines[$i]);
-
- if (('' === $lineStr) || $this->isComment($lineStr)) {
- } elseif ($this->isExtM3u($lineStr)) {
- $tmp = trim(substr($lineStr, 7));
-
- if ($tmp) {
- $data->initAttributes($tmp);
- }
- } else {
- $data->append($this->parseLine($i, $lines));
- }
- }
-
- return $data;
- }
-
- protected function createM3uEntry(): M3uEntry {
- return new M3uEntry();
- }
-
- protected function createM3uData(): M3uData {
- return new M3uData();
- }
-
- /**
- * Parse one line.
- *
- * @param string[] $linesStr
- */
- protected function parseLine(int &$lineNumber, array $linesStr): M3uEntry {
- $entry = $this->createM3uEntry();
- $l = count($linesStr);
-
- while ($lineNumber < $l) {
- $nextLineStr = $linesStr[$lineNumber];
- $nextLineStr = trim($nextLineStr);
-
- if (('' === $nextLineStr) || $this->isComment($nextLineStr) || $this->isExtM3u($nextLineStr)) {
- } else {
- $matched = false;
-
- foreach ($this->getTags() as $availableTag) {
- if ($availableTag::isMatch($nextLineStr)) {
- $matched = true;
- $entry->addExtTag(new $availableTag($nextLineStr));
-
- break;
- }
- }
-
- if (!$matched) {
- $entry->setPath($nextLineStr);
-
- break;
- }
- }
-
- ++$lineNumber;
- }
-
- return $entry;
- }
-
- protected function removeBom(string &$str): void {
- if (0 === strpos($str, '')) {
- $str = substr($str, 3);
- }
- }
-
- protected function isExtM3u(string $lineStr): bool {
- return 0 === stripos($lineStr, '#EXTM3U');
- }
-
- protected function isComment(string $lineStr): bool {
- $matched = false;
-
- foreach ($this->getTags() as $availableTag) {
- if ($availableTag::isMatch($lineStr)) {
- $matched = true;
-
- break;
- }
- }
-
- return !$matched && (0 === strpos($lineStr, '#')) && !$this->isExtM3u($lineStr);
- }
-}
-
-class M3uData extends ArrayIterator {
- use TagAttributesTrait;
-
- public function __toString(): string {
- $out = rtrim('#EXTM3U ' . $this->getAttributesString()) . "\n";
-
- foreach ($this as $entry) {
- $out .= $entry . "\n";
- }
-
- return rtrim($out);
- }
-}
-
-class ExtInf implements ExtTagInterface {
- use TagAttributesTrait;
-
- /**
- * @var string
- */
- private $title;
- /**
- * @var int
- */
- private $duration;
-
- /**
- * #EXTINF:-1 tvg-name=Первый_HD tvg-logo="Первый канал" deinterlace=4 group-title="Эфирные каналы",Первый канал HD.
- */
- public function __construct(?string $lineStr = null) {
- if (null !== $lineStr) {
- $this->make($lineStr);
- }
- }
-
- public function __toString(): string {
- return '#EXTINF: ' . $this->getDuration() . ' ' . $this->getAttributesString() . ', ' . $this->getTitle();
- }
-
- /**
- * @return $this
- */
- public function setTitle(string $title): ExtInf {
- $this->title = $title;
-
- return $this;
- }
-
- public function getTitle(): string {
- return $this->title;
- }
-
- /**
- * @return $this
- */
- public function setDuration(int $duration): ExtInf {
- $this->duration = $duration;
-
- return $this;
- }
-
- public function getDuration(): int {
- return $this->duration;
- }
-
- public static function isMatch(string $lineStr): bool {
- return 0 === stripos($lineStr, '#EXTINF:');
- }
-
- /**
- * @see http://l189-238-14.cn.ru/api-doc/m3u-extending.html
- */
- protected function make(string $lineStr): void {
- $dataLineStr = substr($lineStr, strlen('#EXTINF:'));
- $dataLineStr = trim($dataLineStr);
- preg_match('/^(-?\\d+)\\s*(?:(?:[^=]+=["\'][^"\']*["\'])|(?:[^=]+=[^ ]*))*,(.*)$/', $dataLineStr, $matches);
-
- if (!isset($matches[1], $matches[2])) {
- $commaPos = strpos($dataLineStr, ',');
-
- if ($commaPos !== false) {
- $this->setDuration(intval($dataLineStr));
- $this->setTitle(trim(substr($dataLineStr, $commaPos + 1)));
- } else {
- $this->setDuration(0);
- $this->setTitle(trim($dataLineStr));
- }
-
- return;
- }
-
- $this->setDuration((int) $matches[1]);
- $this->setTitle(trim($matches[2]));
- $attributes = preg_replace('/^' . preg_quote($matches[1], '/') . '(.*)' . preg_quote($matches[2], '/') . '$/', '$1', $dataLineStr);
- $splitAttributes = explode(' ', $attributes, 2);
-
- if (isset($splitAttributes[1]) && ($trimmedAttributes = trim($splitAttributes[1]))) {
- $this->initAttributes($trimmedAttributes);
- }
- }
-}
-
-class ExtLogo implements ExtTagInterface {
- /**
- * @var string
- */
- private $logo;
-
- /**
- * #EXTLOGO:http://cdn1.siol.tv/logo/93x78/slo2.png.
- */
- public function __construct(?string $lineStr = null) {
- if (null !== $lineStr) {
- $this->makeData($lineStr);
- }
- }
-
- public function __toString(): string {
- return '#EXTLOGO: ' . $this->getLogo();
- }
-
- public function getLogo(): string {
- return $this->logo;
- }
-
- /**
- * @return $this
- */
- public function setLogo(string $logo): ExtLogo {
- $this->logo = $logo;
-
- return $this;
- }
-
- public static function isMatch(string $lineStr): bool {
- return 0 === stripos($lineStr, '#EXTLOGO:');
- }
-
- protected function makeData(string $lineStr): void {
- $tmp = substr($lineStr, strlen('#EXTLOGO:'));
- $logo = trim($tmp);
- $this->setLogo($logo);
- }
-}
-
-class ExtTv implements ExtTagInterface {
- /**
- * @var string[]
- */
- private $tags;
- /**
- * @var string
- */
- private $language;
- /**
- * @var string
- */
- private $xmlTvId;
- /**
- * @var null|string
- */
- private $iconUrl;
-
- /**
- * #EXTTV:nacionalni,hd;slovenski;SLO1;http://cdn1.siol.tv/logo/93x78/slo2.png.
- */
- public function __construct(?string $lineStr = null) {
- if (null !== $lineStr) {
- $this->makeData($lineStr);
- }
- }
-
- public function __toString(): string {
- return '#EXTTV: ' . implode(',', $this->getTags()) . ';' . $this->getLanguage() . ';' . $this->getXmlTvId() . ($this->getIconUrl() ? ';' . $this->getIconUrl() : '');
- }
-
- /**
- * @return string[]
- */
- public function getTags(): array {
- return $this->tags;
- }
-
- /**
- * @param string[] $tags
- *
- * @return $this
- */
- public function setTags(array $tags): ExtTv {
- $this->tags = $tags;
-
- return $this;
- }
-
- public function getLanguage(): string {
- return $this->language;
- }
-
- /**
- * @return $this
- */
- public function setLanguage(string $language): ExtTv {
- $this->language = $language;
-
- return $this;
- }
-
- public function getXmlTvId(): string {
- return $this->xmlTvId;
- }
-
- /**
- * @return $this
- */
- public function setXmlTvId(string $xmlTvId): ExtTv {
- $this->xmlTvId = $xmlTvId;
-
- return $this;
- }
-
- public function getIconUrl(): ?string {
- return $this->iconUrl;
- }
-
- /**
- * @return $this
- */
- public function setIconUrl(?string $iconUrl): ExtTv {
- $this->iconUrl = $iconUrl;
-
- return $this;
- }
-
- public static function isMatch(string $lineStr): bool {
- return 0 === stripos($lineStr, '#EXTTV:');
- }
-
- protected function makeData(string $lineStr): void {
- $tmp = substr($lineStr, strlen('#EXTTV:'));
- $split = explode(';', $tmp, 4);
- $this->setTags(array_map('trim', explode(',', $split[0])));
- $this->setLanguage(trim($split[1]));
- $this->setXmlTvId(trim($split[2]));
-
- if (isset($split[3])) {
- $this->setIconUrl(trim($split[3]));
- }
- }
-}
diff --git a/src/includes/libs/m3u_v2.php b/src/includes/libs/m3u_v2.php
deleted file mode 100644
index 9569fb5f..00000000
--- a/src/includes/libs/m3u_v2.php
+++ /dev/null
@@ -1,798 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-class Config
-{
- private $data;
-
- public function __construct(array $data)
- {
- $this->data = $data;
- }
-
- public function get($key, $default = NULL)
- {
- if (!is_string($key)) {
- throw new InvalidArgumentException(sprintf('$key can only be string, got %s', var_export($key, true)));
- }
-
- if (array_key_exists($key, $this->data)) {
- return $this->data[$key];
- }
-
- if (NULL === $default) {
- throw new OutOfBoundsException(sprintf('Unknown config "%s"', $key));
- }
-
- return $default;
- }
-
- protected function getData()
- {
- return $this->data;
- }
-}
-
-class AttributeListParser
-{
- private $valueParsers;
- private $attributeStringToArray;
-
- public function __construct(Config $valueParsers, AttributeStringToArray $attributeStringToArray)
- {
- $this->valueParsers = $valueParsers;
- $this->attributeStringToArray = $attributeStringToArray;
- }
-
- public function parse($string, array $types)
- {
- $attributeParse = $this->attributeStringToArray;
- $attributes = $attributeParse($string);
- $result = new ArrayObject();
-
- foreach ($attributes as $key => $value) {
- if (!isset($types[$key])) {
- continue;
- }
-
- $type = $types[$key];
- $parse = $this->valueParsers->get($type);
-
- if (is_callable($parse)) {
- $result[$key] = $parse($value);
- }
- }
-
- return $result;
- }
-}
-
-class DataBuilder
-{
- private $currentMediaSegment;
- private $result;
- private $lastAddedTag;
-
- public function addUri($uri)
- {
- if (NULL !== $this->currentMediaSegment) {
- $this->currentMediaSegment['uri'] = $uri;
- $this->currentMediaSegment = NULL;
- return NULL;
- }
-
- if ($this->lastAddedTag['definition']->isUriAware()) {
- $this->lastAddedTag['value']['uri'] = $uri;
- return NULL;
- }
-
- throw new DataBuildingException('uri found, but doesn\'t know how to handle it');
- }
-
- public function addTag(TagDefinition $definition, $data)
- {
- $parent = $this->result;
-
- if ('media-segment' === $definition->getCategory()) {
- if (NULL === $this->currentMediaSegment) {
- $this->currentMediaSegment = new ArrayObject();
- $this->result['mediaSegments'][] = $this->currentMediaSegment;
- }
-
- $parent = $this->currentMediaSegment;
- }
-
- $this->lastAddedTag = ['definition' => $definition, 'value' => $data];
-
- if ($definition->isMultiple()) {
- $parent[$definition->getTag()][] = $data;
- return NULL;
- }
-
- $parent[$definition->getTag()] = $data;
- }
-
- public function getResult()
- {
- return $this->result;
- }
-
- public function reset()
- {
- $this->currentMediaSegment = NULL;
- $this->result = new ArrayObject();
- $this->lastAddedTag = NULL;
- }
-}
-
-class DataBuildingException
-{
-}
-
-class Parser
-{
- private $tagDefinitions;
- private $valueParsers;
- private $dataBuilder;
-
- public function __construct(TagDefinitions $tagDefinitions, Config $valueParsers, DataBuilder $dataBuilder)
- {
- $this->tagDefinitions = $tagDefinitions;
- $this->valueParsers = $valueParsers;
- $this->dataBuilder = $dataBuilder;
- }
-
- public function parse(Lines $lines)
- {
- $this->dataBuilder->reset();
-
- foreach ($lines as $line) {
- if ($line->isType(Line::TYPE_URI)) {
- $this->dataBuilder->addUri($line->getValue());
- continue;
- }
-
- $tag = $line->getTag();
- $definition = $this->tagDefinitions->get($tag);
-
- if (NULL === $definition) {
- continue;
- }
-
- $valueType = $definition->getValueType();
- $value = $line->getValue();
- $parse = $this->valueParsers->get($valueType);
-
- if (is_callable($parse)) {
- $value = ('attribute-list' === $valueType ? $parse($value, $definition->getAttributeTypes()) : $parse($value));
- }
-
- $this->dataBuilder->addTag($definition, $value);
- }
-
- return $this->dataBuilder->getResult();
- }
-}
-
-class Line
-{
- public const TYPE_URI = 'uri';
- public const TYPE_TAG = 'tag';
-
- private $tag;
- private $value;
-
- public function __construct($tag = NULL, $value = NULL)
- {
- if ((NULL === $tag) && (NULL === $value)) {
- throw new InvalidArgumentException('$tag and $value can not both be null');
- }
-
- $this->tag = $tag;
- $this->value = $value;
- }
-
- static public function fromString($line)
- {
- $line = trim($line);
-
- if (empty($line)) {
- return NULL;
- }
-
- if ('#' !== $line[0]) {
- return new self(NULL, $line);
- }
-
- if ('#EXT' !== substr($line, 0, 4)) {
- return NULL;
- }
-
- $line = ltrim($line, '#');
-
- if (empty($line)) {
- return NULL;
- }
-
- list($tag, $value) = array_pad(explode(':', $line, 2), 2, true);
- return new self($tag, $value);
- }
-
- public function getTag()
- {
- return $this->tag;
- }
-
- public function getValue()
- {
- return $this->value;
- }
-
- public function isType($type)
- {
- return $this->getType() === $type;
- }
-
- public function __toString()
- {
- if ($this->isType('uri')) {
- return $this->value;
- }
-
- if (true === $this->value) {
- return sprintf('#%s', $this->tag);
- }
-
- if (false === $this->value) {
- return '';
- }
-
- return sprintf('#%s:%s', $this->tag, $this->value);
- }
-
- private function getType()
- {
- if (NULL !== $this->tag) {
- return 'tag';
- }
-
- return 'uri';
- }
-}
-
-class AttributeListDumper
-{
- private $valueDumper;
-
- public function __construct(Config $valueDumper)
- {
- $this->valueDumper = $valueDumper;
- }
-
- public function dump(ArrayAccess $data, array $types)
- {
- $result = [];
-
- foreach ($data as $key => $value) {
- if (!isset($types[$key])) {
- continue;
- }
-
- $type = $types[$key];
- $dump = $this->valueDumper->get($type);
- $result[] = sprintf('%s=%s', $key, $dump($value));
- }
-
- if (!empty($result)) {
- return implode(',', $result);
- }
- }
-}
-
-class Dumper
-{
- private $tagDefinitions;
- private $valueDumpers;
-
- public function __construct(TagDefinitions $tagDefinitions, Config $valueDumpers)
- {
- $this->tagDefinitions = $tagDefinitions;
- $this->valueDumpers = $valueDumpers;
- }
-
- public function dumpToLines(ArrayAccess $data, Lines $lines)
- {
- $lines->add(new Line('EXTM3U', true));
- $this->iterateTags($this->tagDefinitions->getHeadTags(), $data, $lines);
-
- if (!isset($data['mediaSegments'])) {
- return NULL;
- }
-
- foreach ($data['mediaSegments'] as $mediaSegment) {
- $this->iterateTags($this->tagDefinitions->getMediaSegmentTags(), $mediaSegment, $lines);
- $lines->add(new Line(NULL, $mediaSegment['uri']));
- }
-
- $this->iterateTags($this->tagDefinitions->getFootTags(), $data, $lines);
- }
-
- private function iterateTags(array $tags, ArrayAccess $data, Lines $lines)
- {
- foreach ($tags as $tag) {
- if (!isset($data[$tag])) {
- continue;
- }
-
- $definition = $this->tagDefinitions->get($tag);
- $value = $data[$tag];
-
- if (!$definition->isMultiple()) {
- $this->dumpAndAddToLines($definition, $value, $lines);
- continue;
- }
-
- foreach ($value as $element) {
- $this->dumpAndAddToLines($definition, $element, $lines);
- }
- }
- }
-
- private function dumpValue(TagDefinition $definition, $value)
- {
- $valueType = $definition->getValueType();
- $dump = $this->valueDumpers->get($valueType);
-
- if (!is_callable($dump)) {
- return $value;
- }
-
- if ('attribute-list' === $valueType) {
- return $dump($value, $definition->getAttributeTypes());
- }
-
- return $dump($value);
- }
-
- private function dumpAndAddToLines(TagDefinition $definition, $value, Lines $lines)
- {
- $lines->add(new Line($definition->getTag(), $this->dumpValue($definition, $value)));
-
- if ($definition->isUriAware()) {
- $lines->add(new Line(NULL, $value['uri']));
- }
- }
-}
-
-class DumpingException
-{
-}
-
-class DefinitionException
-{
-}
-
-class TagDefinition
-{
- private $tag;
- private $config;
- private $attributeTypes;
-
- public function __construct($tag, Config $config)
- {
- if (!is_string($tag)) {
- throw new InvalidArgumentException('$tag can only be string, got %s', gettype($tag));
- }
-
- $this->tag = $tag;
- $this->config = $config;
- }
-
- public function getTag()
- {
- return $this->tag;
- }
-
- public function getValueType()
- {
- $type = $this->config->get('type');
-
- if (is_array($type)) {
- $this->attributeTypes = $type;
- return 'attribute-list';
- }
-
- return $type;
- }
-
- public function isMultiple()
- {
- return $this->config->get('multiple', false);
- }
-
- public function getCategory()
- {
- return $this->config->get('category');
- }
-
- public function isUriAware()
- {
- return $this->config->get('uriAware', false);
- }
-
- public function getAttributeTypes()
- {
- return $this->attributeTypes;
- }
-}
-
-class TagDefinitions
-{
- private $definitions;
- private $headTags;
- private $mediaSegmentTags;
- private $footTags;
-
- public function __construct(array $definitions)
- {
- foreach ($definitions as $tag => $definition) {
- $position = $definition['position'];
-
- if ('media-segment' === $definition['category']) {
- $this->mediaSegmentTags[$definition['position']] = $tag;
- continue;
- }
-
- if ($position < 0) {
- $this->headTags[$position] = $tag;
- continue;
- }
-
- $this->footTags[$position] = $tag;
- }
-
- $this->definitions = $definitions;
- ksort($this->headTags);
- ksort($this->mediaSegmentTags);
- ksort($this->footTags);
- }
-
- public function get($tag)
- {
- if (!is_string($tag)) {
- throw new InvalidArgumentException('$tag can only be string, got %s', gettype($tag));
- }
-
- if (!isset($this->definitions[$tag])) {
- return NULL;
- }
-
- return new TagDefinition($tag, new Config($this->definitions[$tag]));
- }
-
- public function getHeadTags()
- {
- return $this->headTags;
- }
-
- public function getMediaSegmentTags()
- {
- return $this->mediaSegmentTags;
- }
-
- public function getFootTags()
- {
- return $this->footTags;
- }
-}
-
-class AttributeStringToArray
-{
- public function __invoke($string)
- {
- if (!is_string($string)) {
- throw new InvalidArgumentException(sprintf('$string can only be string, got %s', gettype($string)));
- }
-
- preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\\1(?=,|$)/', $string, $matches);
- $attrs = [];
-
- foreach ($matches[0] as $attr) {
- list($key, $value) = explode('=', $attr, 2);
- $attrs[$key] = $value;
- }
-
- return $attrs;
- }
-}
-
-class Iso8601Transformer
-{
- static public function fromString($string)
- {
- return new DateTime($string);
- }
-
- static public function toString(DateTime $datetime)
- {
- $timezone = $datetime->format('P');
- return sprintf('%s%s', substr($datetime->format('Y-m-d\\TH:i:s.u'), 0, -3), $timezone);
- }
-}
-
-class Resolution
-{
- private $width;
- private $height;
-
- public function __construct($width, $height)
- {
- $this->width = (int) $width;
- $this->height = (int) $height;
- if (($this->width < 1) || ($this->height < 1)) {
- throw new InvalidArgumentException('$width or $height should be an integer greater than 0');
- }
- }
-
- static public function fromString($string)
- {
- list($width, $height) = explode('x', $string);
- return new self($width, $height);
- }
-
- public function getWidth()
- {
- return $this->width;
- }
-
- public function getHeight()
- {
- return $this->height;
- }
-
- public function __toString()
- {
- return sprintf('%dx%d', $this->width, $this->height);
- }
-}
-
-class Byterange
-{
- private $length;
- private $offset;
-
- public function __construct($length, $offset = NULL)
- {
- $this->length = (int) $length;
-
- if ($this->length < 1) {
- throw new InvalidArgumentException('$length should be an integer greater than 0');
- }
-
- if (NULL === $offset) {
- return NULL;
- }
-
- $this->offset = (int) $offset;
-
- if ($this->offset < 1) {
- throw new InvalidArgumentException('$offset should be an integer greater than 0');
- }
- }
-
- static public function fromString($string)
- {
- list($length, $offset) = array_pad(explode('@', $string), 2, NULL);
- return new self($length, $offset);
- }
-
- public function getLength()
- {
- return $this->length;
- }
-
- public function getOffset()
- {
- return $this->offset;
- }
-
- public function __toString()
- {
- if (NULL === $this->offset) {
- return (string) $this->length;
- }
-
- return sprintf('%d@%d', $this->length, $this->offset);
- }
-}
-
-class Inf
-{
- private $duration;
- private $title;
- private $version;
-
- public function __construct($duration, $title = NULL, $version = 6)
- {
- $this->duration = 1 * $duration;
-
- if ($this->duration < 0) {
- throw new InvalidArgumentException('$duration should not be less than 0');
- }
-
- $this->version = (int) $version;
- if (($this->version < 2) || (7 < $this->version)) {
- throw new InvalidArgumentException(sprintf('$version should be an integer greater than 1 and less than 8'));
- }
-
- if (NULL === $title) {
- return NULL;
- }
-
- $this->title = (string) $title;
- }
-
- static public function fromString($string)
- {
- list($duration, $title) = explode(',', $string);
- return new self($duration, $title);
- }
-
- public function getDuration()
- {
- return $this->duration;
- }
-
- public function setTitle($title)
- {
- $this->title = $title;
- }
-
- public function getTitle()
- {
- return $this->title;
- }
-
- public function __toString()
- {
- if ($this->version < 3) {
- return sprintf('%d,%s', round($this->duration), $this->title);
- }
-
- return sprintf('%.3f,%s', $this->duration, $this->title);
- }
-}
-
-class ParserFacade
-{
- private $parser;
-
- public function parse(StreamInterface $stream)
- {
- if (NULL === $this->parser) {
- $tagDefinitions = new TagDefinitions(require '/home/xc_vm/includes/libs/resources/tags.php');
- $this->parser = new Parser($tagDefinitions, new Config(require '/home/xc_vm/includes/libs/resources/tagValueParsers.php'), new DataBuilder());
- }
-
- return $this->parser->parse(new Lines($stream));
- }
-}
-
-class DumperFacade
-{
- private $dumper;
-
- public function dump(ArrayAccess $data, StreamInterface $stream)
- {
- if (NULL === $this->dumper) {
- $tagDefinitions = new TagDefinitions(require '/home/xc_vm/includes/libs/resources/tags.php');
- $this->dumper = new Dumper($tagDefinitions, new Config(require '/home/xc_vm/includes/libs/resources/tagValueDumpers.php'));
- }
-
- $this->dumper->dumpToLines($data, new Lines($stream));
- }
-}
-
-interface StreamInterface extends Iterator
-{
- public function add($line);
-}
-
-class FileStream extends SplFileObject implements StreamInterface
-{
- public function add($line)
- {
- $this->fwrite($line . "\n");
- }
-}
-
-class TextStream extends ArrayIterator implements StreamInterface
-{
- public function __construct($text = NULL)
- {
- $lines = [];
-
- if (NULL !== $text) {
- $lines = explode("\n", trim($text));
- }
-
- parent::__construct($lines);
- }
-
- public function add($line)
- {
- $this->append($line);
- }
-
- public function __toString()
- {
- return implode("\n", $this->getArrayCopy()) . "\n";
- }
-}
-
-class Lines implements Iterator
-{
- private $stream;
- private $current;
-
- public function __construct(StreamInterface $stream)
- {
- $this->stream = $stream;
- }
-
- public function current()
- {
- return $this->current;
- }
-
- public function add(Line $line)
- {
- $this->stream->add((string) $line);
- }
-
- public function next()
- {
- $this->stream->next();
- }
-
- public function valid()
- {
- $this->current = NULL;
-
- while ((NULL === $this->current) && $this->stream->valid()) {
- if ($this->stream->current()) {
- $line = Line::fromString($this->stream->current());
-
- if (NULL !== $line) {
- $this->current = $line;
- return true;
- }
- }
-
- $this->stream->next();
- }
-
- return false;
- }
-
- public function rewind()
- {
- $this->stream->rewind();
- }
-
- public function key()
- {
- return $this->stream->key();
- }
-}
-
-?>
\ No newline at end of file
diff --git a/src/includes/libs/mobiledetect.php b/src/includes/libs/mobiledetect.php
deleted file mode 100644
index 37ae9f30..00000000
--- a/src/includes/libs/mobiledetect.php
+++ /dev/null
@@ -1,1654 +0,0 @@
- (since 2012)
- * @author Nick Ilyin
- * @author: Victor Stanciu (original author)
- *
- * @version 2.8.45
- *
- * Auto-generated isXXXX() magic methods.
- * php -a examples/dump_magic_methods.php
- *
- * @method bool isiPhone()
- * @method bool isBlackBerry()
- * @method bool isPixel()
- * @method bool isHTC()
- * @method bool isNexus()
- * @method bool isDell()
- * @method bool isMotorola()
- * @method bool isSamsung()
- * @method bool isLG()
- * @method bool isSony()
- * @method bool isAsus()
- * @method bool isXiaomi()
- * @method bool isNokiaLumia()
- * @method bool isMicromax()
- * @method bool isPalm()
- * @method bool isVertu()
- * @method bool isPantech()
- * @method bool isFly()
- * @method bool isWiko()
- * @method bool isiMobile()
- * @method bool isSimValley()
- * @method bool isWolfgang()
- * @method bool isAlcatel()
- * @method bool isNintendo()
- * @method bool isAmoi()
- * @method bool isINQ()
- * @method bool isOnePlus()
- * @method bool isGenericPhone()
- * @method bool isiPad()
- * @method bool isNexusTablet()
- * @method bool isGoogleTablet()
- * @method bool isSamsungTablet()
- * @method bool isKindle()
- * @method bool isSurfaceTablet()
- * @method bool isHPTablet()
- * @method bool isAsusTablet()
- * @method bool isBlackBerryTablet()
- * @method bool isHTCtablet()
- * @method bool isMotorolaTablet()
- * @method bool isNookTablet()
- * @method bool isAcerTablet()
- * @method bool isToshibaTablet()
- * @method bool isLGTablet()
- * @method bool isFujitsuTablet()
- * @method bool isPrestigioTablet()
- * @method bool isLenovoTablet()
- * @method bool isDellTablet()
- * @method bool isYarvikTablet()
- * @method bool isMedionTablet()
- * @method bool isArnovaTablet()
- * @method bool isIntensoTablet()
- * @method bool isIRUTablet()
- * @method bool isMegafonTablet()
- * @method bool isEbodaTablet()
- * @method bool isAllViewTablet()
- * @method bool isArchosTablet()
- * @method bool isAinolTablet()
- * @method bool isNokiaLumiaTablet()
- * @method bool isSonyTablet()
- * @method bool isPhilipsTablet()
- * @method bool isCubeTablet()
- * @method bool isCobyTablet()
- * @method bool isMIDTablet()
- * @method bool isMSITablet()
- * @method bool isSMiTTablet()
- * @method bool isRockChipTablet()
- * @method bool isFlyTablet()
- * @method bool isbqTablet()
- * @method bool isHuaweiTablet()
- * @method bool isNecTablet()
- * @method bool isPantechTablet()
- * @method bool isBronchoTablet()
- * @method bool isVersusTablet()
- * @method bool isZyncTablet()
- * @method bool isPositivoTablet()
- * @method bool isNabiTablet()
- * @method bool isKoboTablet()
- * @method bool isDanewTablet()
- * @method bool isTexetTablet()
- * @method bool isPlaystationTablet()
- * @method bool isTrekstorTablet()
- * @method bool isPyleAudioTablet()
- * @method bool isAdvanTablet()
- * @method bool isDanyTechTablet()
- * @method bool isGalapadTablet()
- * @method bool isMicromaxTablet()
- * @method bool isKarbonnTablet()
- * @method bool isAllFineTablet()
- * @method bool isPROSCANTablet()
- * @method bool isYONESTablet()
- * @method bool isChangJiaTablet()
- * @method bool isGUTablet()
- * @method bool isPointOfViewTablet()
- * @method bool isOvermaxTablet()
- * @method bool isHCLTablet()
- * @method bool isDPSTablet()
- * @method bool isVistureTablet()
- * @method bool isCrestaTablet()
- * @method bool isMediatekTablet()
- * @method bool isConcordeTablet()
- * @method bool isGoCleverTablet()
- * @method bool isModecomTablet()
- * @method bool isVoninoTablet()
- * @method bool isECSTablet()
- * @method bool isStorexTablet()
- * @method bool isVodafoneTablet()
- * @method bool isEssentielBTablet()
- * @method bool isRossMoorTablet()
- * @method bool isiMobileTablet()
- * @method bool isTolinoTablet()
- * @method bool isAudioSonicTablet()
- * @method bool isAMPETablet()
- * @method bool isSkkTablet()
- * @method bool isTecnoTablet()
- * @method bool isJXDTablet()
- * @method bool isiJoyTablet()
- * @method bool isFX2Tablet()
- * @method bool isXoroTablet()
- * @method bool isViewsonicTablet()
- * @method bool isVerizonTablet()
- * @method bool isOdysTablet()
- * @method bool isCaptivaTablet()
- * @method bool isIconbitTablet()
- * @method bool isTeclastTablet()
- * @method bool isOndaTablet()
- * @method bool isJaytechTablet()
- * @method bool isBlaupunktTablet()
- * @method bool isDigmaTablet()
- * @method bool isEvolioTablet()
- * @method bool isLavaTablet()
- * @method bool isAocTablet()
- * @method bool isMpmanTablet()
- * @method bool isCelkonTablet()
- * @method bool isWolderTablet()
- * @method bool isMediacomTablet()
- * @method bool isMiTablet()
- * @method bool isNibiruTablet()
- * @method bool isNexoTablet()
- * @method bool isLeaderTablet()
- * @method bool isUbislateTablet()
- * @method bool isPocketBookTablet()
- * @method bool isKocasoTablet()
- * @method bool isHisenseTablet()
- * @method bool isHudl()
- * @method bool isTelstraTablet()
- * @method bool isGenericTablet()
- * @method bool isAndroidOS()
- * @method bool isBlackBerryOS()
- * @method bool isPalmOS()
- * @method bool isSymbianOS()
- * @method bool isWindowsMobileOS()
- * @method bool isWindowsPhoneOS()
- * @method bool isiOS()
- * @method bool isiPadOS()
- * @method bool isSailfishOS()
- * @method bool isMeeGoOS()
- * @method bool isMaemoOS()
- * @method bool isJavaOS()
- * @method bool iswebOS()
- * @method bool isbadaOS()
- * @method bool isBREWOS()
- * @method bool isChrome()
- * @method bool isDolfin()
- * @method bool isOpera()
- * @method bool isSkyfire()
- * @method bool isEdge()
- * @method bool isIE()
- * @method bool isFirefox()
- * @method bool isBolt()
- * @method bool isTeaShark()
- * @method bool isBlazer()
- * @method bool isSafari()
- * @method bool isWeChat()
- * @method bool isUCBrowser()
- * @method bool isbaiduboxapp()
- * @method bool isbaidubrowser()
- * @method bool isDiigoBrowser()
- * @method bool isMercury()
- * @method bool isObigoBrowser()
- * @method bool isNetFront()
- * @method bool isGenericBrowser()
- * @method bool isPaleMoon()
- * @method bool isBot()
- * @method bool isMobileBot()
- * @method bool isDesktopMode()
- * @method bool isTV()
- * @method bool isWebKit()
- * @method bool isConsole()
- * @method bool isWatch()
-
- */
-class Mobile_Detect {
- /**
- * Mobile detection type.
- *
- * @deprecated since version 2.6.9
- */
- const DETECTION_TYPE_MOBILE = 'mobile';
-
- /**
- * Extended detection type.
- *
- * @deprecated since version 2.6.9
- */
- const DETECTION_TYPE_EXTENDED = 'extended';
-
- /**
- * A frequently used regular expression to extract version #s.
- *
- * @deprecated since version 2.6.9
- */
- const VER = '([\w._\+]+)';
-
- /**
- * Top-level device.
- */
- const MOBILE_GRADE_A = 'A';
-
- /**
- * Mid-level device.
- */
- const MOBILE_GRADE_B = 'B';
-
- /**
- * Low-level device.
- */
- const MOBILE_GRADE_C = 'C';
-
- /**
- * Stores the version number of the current release.
- */
- const VERSION = '2.8.45';
-
- /**
- * A type for the version() method indicating a string return value.
- */
- const VERSION_TYPE_STRING = 'text';
-
- /**
- * A type for the version() method indicating a float return value.
- */
- const VERSION_TYPE_FLOAT = 'float';
-
- /**
- * A cache for resolved matches
- * @var array
- */
- protected $cache = array();
-
- /**
- * The User-Agent HTTP header is stored in here.
- * @var string
- */
- protected $userAgent = null;
-
- /**
- * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
- * @var array
- */
- protected $httpHeaders = array();
-
- /**
- * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
- * @var array
- */
- protected $cloudfrontHeaders = array();
-
- /**
- * The matching Regex.
- * This is good for debug.
- * @var string
- */
- protected $matchingRegex = null;
-
- /**
- * The matches extracted from the regex expression.
- * This is good for debug.
- *
- * @var string
- */
- protected $matchesArray = null;
-
- /**
- * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
- *
- * @deprecated since version 2.6.9
- *
- * @var string
- */
- protected $detectionType = self::DETECTION_TYPE_MOBILE;
-
- /**
- * HTTP headers that trigger the 'isMobile' detection
- * to be true.
- *
- * @var array
- */
- protected static $mobileHeaders = array(
-
- 'HTTP_ACCEPT' => array('matches' => array(
- // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
- 'application/x-obml2d',
- // BlackBerry devices.
- 'application/vnd.rim.html',
- 'text/vnd.wap.wml',
- 'application/vnd.wap.xhtml+xml'
- )),
- 'HTTP_X_WAP_PROFILE' => null,
- 'HTTP_X_WAP_CLIENTID' => null,
- 'HTTP_WAP_CONNECTION' => null,
- 'HTTP_PROFILE' => null,
- // Reported by Opera on Nokia devices (eg. C3).
- 'HTTP_X_OPERAMINI_PHONE_UA' => null,
- 'HTTP_X_NOKIA_GATEWAY_ID' => null,
- 'HTTP_X_ORANGE_ID' => null,
- 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
- 'HTTP_X_HUAWEI_USERID' => null,
- // Reported by Windows Smartphones.
- 'HTTP_UA_OS' => null,
- // Reported by Verizon, Vodafone proxy system.
- 'HTTP_X_MOBILE_GATEWAY' => null,
- // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
- 'HTTP_X_ATT_DEVICEID' => null,
- // Seen this on a HTC.
- 'HTTP_UA_CPU' => array('matches' => array('ARM')),
- );
-
- /**
- * List of mobile devices (phones).
- *
- * @var array
- */
- protected static $phoneDevices = array(
- 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
- 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+',
- 'Pixel' => '; \bPixel\b',
- 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel',
- 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 5X|Nexus 6',
- // @todo: Is 'Dell Streak' a tablet or a phone? ;)
- 'Dell' => 'Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
- 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b|XT1068|XT1092|XT1052',
- 'Samsung' => '\bSamsung\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F|SM-G610F|SM-G981B|SM-G892A|SM-A530F|SM-G988N|SM-G781B|SM-A805N|SM-G965F',
- 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710',
- 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533|SOV34|601SO|F8332',
- 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile|ASUS_Z01QD|ASUS_X00TD',
- 'Xiaomi' => '^(?!.*\bx11\b).*xiaomi.*$|POCOPHONE F1|\bMI\b 8|\bMi\b 10|Redmi Note 9S|Redmi 5A|Redmi Note 5A Prime|Redmi Note 7 Pro|N2G47H|M2001J2G|M2001J2I|M1805E10A|M2004J11G|M1902F1G|M2002J9G|M2004J19G|M2003J6A1G|M2012K11C|M2007J1SC',
- 'NokiaLumia' => 'Lumia [0-9]{3,4}',
- // http://www.micromaxinfo.com/mobiles/smartphones
- // Added because the codes might conflict with Acer Tablets.
- 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
- // @todo Complete the regex.
- 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
- 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
- // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
- // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
- 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
- // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
- 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
- // http://fr.wikomobile.com
- 'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
- 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
- // Added simvalley mobile just for fun. They have some interesting devices.
- // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
- 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
- // Wolfgang - a brand that is sold by Aldi supermarkets.
- // http://www.wolfgangmobile.com/
- 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
- 'Alcatel' => 'Alcatel',
- 'Nintendo' => 'Nintendo (3DS|Switch)',
- // http://en.wikipedia.org/wiki/Amoi
- 'Amoi' => 'Amoi',
- // http://en.wikipedia.org/wiki/INQ
- 'INQ' => 'INQ',
- 'OnePlus' => 'ONEPLUS',
- // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
- 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',
- );
-
- /**
- * List of tablet devices.
- *
- * @var array
- */
- protected static $tabletDevices = array(
- // @todo: check for mobile friendly emails topic.
- 'iPad' => 'iPad|iPad.*Mobile',
- // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
- // @see #442
- // @todo Merge NexusTablet into GoogleTablet.
- 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
- // https://en.wikipedia.org/wiki/Pixel_C
- 'GoogleTablet' => 'Android.*Pixel C',
- 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615|SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860|SM-T536|SM-T837A|SM-X200|SM-T220|SM-T870|SM-X906C|SM-X700|SM-X706|SM-X706B|SM-X706U|SM-X706N|SM-X800|SM-X806|SM-X806B|SM-X806U|SM-X806N|SM-X900|SM-X906|SM-X906B|SM-X906U|SM-X906N|SM-P613', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
- // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
- 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)',
- // Only the Surface tablets with Windows RT are considered mobile.
- // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
- 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
- // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
- 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
- // Watch out for PadFone, see #132.
- // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
- 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K01A | K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\bP027\b|\bP024\b|\bP00C\b',
- 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
- 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
- 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
- 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
- // http://www.acer.ro/ac/ro/RO/content/drivers
- // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
- // http://us.acer.com/ac/en/US/content/group/tablets
- // http://www.acer.de/ac/de/DE/content/models/tablets/
- // Can conflict with Micromax and Motorola phones codes.
- 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b|\bA3-A20\b|\bA3-A30|A3-A40',
- // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
- // http://us.toshiba.com/tablets/tablet-finder
- // http://www.toshiba.co.jp/regza/tablet/
- 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
- // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
- // http://www.lg.com/us/tablets
- 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
- 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
- // Prestigio Tablets http://www.prestigio.com/support
- 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
- // http://support.lenovo.com/en_GB/downloads/default.page?#
- 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F|TB-X704L|TB-J606F|TB-X606F|TB-X306X|YT-J706X',
- // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
- 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
- 'XiaomiTablet' => '21051182G',
- // http://www.yarvik.com/en/matrix/tablets/
- 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
- 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
- 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
- // http://www.intenso.de/kategorie_en.php?kategorie=33
- // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
- 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
- // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
- 'IRUTablet' => 'M702pro',
- 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
- // http://www.e-boda.ro/tablete-pc.html
- 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
- // http://www.allview.ro/produse/droseries/lista-tablete-pc/
- 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
- // http://wiki.archosfans.com/index.php?title=Main_Page
- // @note Rewrite the regex format after we add more UAs.
- 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
- // http://www.ainol.com/plugin.php?identifier=ainol&module=product
- 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
- 'NokiaLumiaTablet' => 'Lumia 2520',
- // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
- // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
- // http://www.sony.jp/support/tablet/
- 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712',
- // http://www.support.philips.com/support/catalog/worldproducts.jsp?userLanguage=en&userCountry=cn&categoryid=3G_LTE_TABLET_SU_CN_CARE&title=3G%20tablets%20/%20LTE%20range&_dyncharset=UTF-8
- 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
- // db + http://www.cube-tablet.com/buy-products.html
- 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
- // http://www.cobyusa.com/?p=pcat&pcat_id=3001
- 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
- // http://www.match.net.cn/products.asp
- 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10',
- // http://www.msi.com/support
- // @todo Research the Windows Tablets.
- 'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
- // @todo http://www.kyoceramobile.com/support/drivers/
- // 'KyoceraTablet' => null,
- // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
- // 'IntextTablet' => null,
- // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
- // http://www.imp3.net/14/show.php?itemid=20454
- 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
- // http://www.rock-chips.com/index.php?do=prod&pid=2
- 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
- // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
- 'FlyTablet' => 'IQ310|Fly Vision',
- // http://www.bqreaders.com/gb/tablets-prices-sale.html
- 'bqTablet' => 'Android.*(bq)?.*\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\b|Maxwell.*Lite|Maxwell.*Plus',
- // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
- // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
- 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19|KOB2-L09|BG2-U01|BG2-W09|BG2-U03',
- // Nec or Medias Tab
- 'NecTablet' => '\bN-06D|\bN-08D',
- // Pantech Tablets: http://www.pantechusa.com/phones/
- 'PantechTablet' => 'Pantech.*P4100',
- // Broncho Tablets: http://www.broncho.cn/ (hard to find)
- 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
- // http://versusuk.com/support.html
- 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
- // http://www.zync.in/index.php/our-products/tablet-phablets
- 'ZyncTablet' => 'z1000|Z99 2G|z930|z990|z909|Z919|z900', // Removed "z999" because of https://github.com/serbanghita/Mobile-Detect/issues/717
- // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
- 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
- // https://www.nabitablet.com/
- 'NabiTablet' => 'Android.*\bNabi',
- 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
- // French Danew Tablets http://www.danew.com/produits-tablette.php
- 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
- // Texet Tablets and Readers http://www.texet.ru/tablet/
- 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
- // Avoid detecting 'PLAYSTATION 3' as mobile.
- 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
- // http://www.trekstor.de/surftabs.html
- 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
- // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
- 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
- // http://www.advandigital.com/index.php?link=content-product&jns=JP001
- // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
- 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ',
- // http://www.danytech.com/category/tablet-pc
- 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1',
- // http://www.galapad.net/product.html ; https://github.com/serbanghita/Mobile-Detect/issues/761
- 'GalapadTablet' => 'Android [0-9.]+; [a-z-]+; \bG1\b',
- // http://www.micromaxinfo.com/tablet/funbook
- 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
- // http://www.karbonnmobiles.com/products_tablet.php
- 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
- // http://www.myallfine.com/Products.asp
- 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
- // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
- 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
- // http://www.yonesnav.com/products/products.php
- 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
- // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
- // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
- 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
- // http://www.gloryunion.cn/products.asp
- // http://www.allwinnertech.com/en/apply/mobile.html
- // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
- // @todo: Softwiner tablets?
- // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
- 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G
- // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
- 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
- // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
- // @todo: add more tests.
- 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027',
- // http://hclmetablet.com/India/index.php
- 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
- // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
- 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
- // http://www.visture.com/index.asp
- 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
- // http://www.mijncresta.nl/tablet
- 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
- // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
- 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
- // Concorde tab
- 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
- // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
- 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042',
- // Modecom Tablets - http://www.modecom.eu/tablets/portal/
- 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
- // Vonino Tablets
- 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
- // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
- 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
- // Storex Tablets - http://storex.fr/espace_client/support.html
- // @note: no need to add all the tablet codes since they are guided by the first regex.
- 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
- // Generic Vodafone tablets.
- 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400',
- // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
- // Aka: http://www.essentielb.fr/
- 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
- // Ross & Moor - http://ross-moor.ru/
- 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
- // i-mobile http://product.i-mobilephone.com/Mobile_Device
- 'iMobileTablet' => 'i-mobile i-note',
- // http://www.tolino.de/de/vergleichen/
- 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
- // AudioSonic - a Kmart brand
- // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72¤tPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1
- 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
- // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
- // @todo: add them gradually to avoid conflicts.
- 'AMPETablet' => 'Android.* A78 ',
- // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
- 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
- // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
- 'TecnoTablet' => 'TECNO P9|TECNO DP8D',
- // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
- 'JXDTablet' => 'Android.* \b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
- // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
- 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
- // http://www.intracon.eu/tablet
- 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
- // http://www.xoro.de/produkte/
- // @note: Might be the same brand with 'Simply tablets'
- 'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151',
- // http://www1.viewsonic.com/products/computing/tablets/
- 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
- // https://www.verizonwireless.com/tablets/verizon/
- 'VerizonTablet' => 'QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1',
- // http://www.odys.de/web/internet-tablet_en.html
- 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
- // http://www.captiva-power.de/products.html#tablets-en
- 'CaptivaTablet' => 'CAPTIVA PAD',
- // IconBIT - http://www.iconbit.com/products/tablets/
- 'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S',
- // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
- 'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98 Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98 3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d 3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18 3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h 3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi',
- // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
- 'OndaTablet' => '\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\b[\s]+|V10 \b4G\b',
- 'JaytechTablet' => 'TPC-PA762',
- 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
- // http://www.digma.ru/support/download/
- // @todo: Ebooks also (if requested)
- 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
- // http://www.evolioshop.com/ro/tablete-pc.html
- // http://www.evolio.ro/support/downloads_static.html?cat=2
- // @todo: Research some more
- 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
- // @todo http://www.lavamobiles.com/tablets-data-cards
- 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
- // http://www.breezetablet.com/
- 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
- // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
- 'MpmanTablet' => 'MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\bMPG7\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010',
- // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
- 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
- // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
- 'WolderTablet' => 'miTab \b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\b',
- 'MediacomTablet' => 'M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA',
- // http://www.mi.com/en
- 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
- // http://www.nbru.cn/index.html
- 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
- // http://navroad.com/products/produkty/tablety/
- // http://navroad.com/products/produkty/tablety/
- 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
- // http://leader-online.com/new_site/product-category/tablets/
- // http://www.leader-online.net.au/List/Tablet
- 'LeaderTablet' => 'TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100',
- // http://www.datawind.com/ubislate/
- 'UbislateTablet' => 'UbiSlate[\s]?7C',
- // http://www.pocketbook-int.com/ru/support
- 'PocketBookTablet' => 'Pocketbook',
- // http://www.kocaso.com/product_tablet.html
- 'KocasoTablet' => '\b(TB-1207)\b',
- // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
- 'HisenseTablet' => '\b(F5281|E2371)\b',
- // http://www.tesco.com/direct/hudl/
- 'Hudl' => 'Hudl HT7S3|Hudl 2',
- // http://www.telstra.com.au/home-phone/thub-2/
- 'TelstraTablet' => 'T-Hub2',
- 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b|\bQTAQZ3\b|WVT101|TM1088|KT107'
- );
-
- /**
- * List of mobile Operating Systems.
- *
- * @var array
- */
- protected static $operatingSystems = array(
- 'AndroidOS' => 'Android',
- 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
- 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
- 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
- // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
- 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;',
- // @reference: http://en.wikipedia.org/wiki/Windows_Phone
- // http://wifeng.cn/?r=blog&a=view&id=106
- // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
- // http://msdn.microsoft.com/library/ms537503.aspx
- // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
- 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
- 'iOS' => '\biPhone.*Mobile|\biPod|\biPad|AppleCoreMedia',
- // https://en.wikipedia.org/wiki/IPadOS
- 'iPadOS' => 'CPU OS 13',
- // @reference https://en.m.wikipedia.org/wiki/Sailfish_OS
- // https://sailfishos.org/
- 'SailfishOS' => 'Sailfish',
- // http://en.wikipedia.org/wiki/MeeGo
- // @todo: research MeeGo in UAs
- 'MeeGoOS' => 'MeeGo',
- // http://en.wikipedia.org/wiki/Maemo
- // @todo: research Maemo in UAs
- 'MaemoOS' => 'Maemo',
- 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
- 'webOS' => 'webOS|hpwOS',
- 'badaOS' => '\bBada\b',
- 'BREWOS' => 'BREW',
- );
-
- /**
- * List of mobile User Agents.
- *
- * IMPORTANT: This is a list of only mobile browsers.
- * Mobile Detect 2.x supports only mobile browsers,
- * it was never designed to detect all browsers.
- * The change will come in 2017 in the 3.x release for PHP7.
- *
- * @var array
- */
- protected static $browsers = array(
- //'Vivaldi' => 'Vivaldi',
- // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
- 'Chrome' => '\bCrMo\b|CriOS.*Mobile|Android.*Chrome/[.0-9]* Mobile',
- 'Dolfin' => '\bDolfin\b',
- 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+',
- 'Skyfire' => 'Skyfire',
- // Added "Edge on iOS" https://github.com/serbanghita/Mobile-Detect/issues/764
- 'Edge' => 'EdgiOS.*Mobile|Mobile Safari/[.0-9]* Edge',
- 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
- 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS.*Mobile',
- 'Bolt' => 'bolt',
- 'TeaShark' => 'teashark',
- 'Blazer' => 'Blazer',
- // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
- // Excluded "Edge on iOS" https://github.com/serbanghita/Mobile-Detect/issues/764
- 'Safari' => 'Version((?!\bEdgiOS\b).)*Mobile.*Safari|Safari.*Mobile|MobileSafari',
- // http://en.wikipedia.org/wiki/Midori_(web_browser)
- //'Midori' => 'midori',
- //'Tizen' => 'Tizen',
- 'WeChat' => '\bMicroMessenger\b',
- 'UCBrowser' => 'UC.*Browser|UCWEB',
- 'baiduboxapp' => 'baiduboxapp',
- 'baidubrowser' => 'baidubrowser',
- // https://github.com/serbanghita/Mobile-Detect/issues/7
- 'DiigoBrowser' => 'DiigoBrowser',
- // http://www.puffinbrowser.com/index.php
- // https://github.com/serbanghita/Mobile-Detect/issues/752
- // 'Puffin' => 'Puffin',
- // http://mercury-browser.com/index.html
- 'Mercury' => '\bMercury\b',
- // http://en.wikipedia.org/wiki/Obigo_Browser
- 'ObigoBrowser' => 'Obigo',
- // http://en.wikipedia.org/wiki/NetFront
- 'NetFront' => 'NF-Browser',
- // @reference: http://en.wikipedia.org/wiki/Minimo
- // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
- 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
- // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
- 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
- );
-
- /**
- * Utilities.
- *
- * @var array
- */
- protected static $utilities = array(
- // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
- // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
- // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
- // https://developers.facebook.com/docs/sharing/webmasters/crawler/
- 'Bot' => 'Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp|AspiegelBot|Semrush|DotBot|PetalBot|MetadataScraper',
- 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
- 'DesktopMode' => 'WPDesktop',
- 'TV' => 'SonyDTV|HbbTV', // experimental
- 'WebKit' => '(webkit)[ /]([\w.]+)',
- // @todo: Include JXD consoles.
- 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\b',
- 'Watch' => 'SM-V700',
- );
-
- /**
- * All possible HTTP headers that represent the
- * User-Agent string.
- *
- * @var array
- */
- protected static $uaHttpHeaders = array(
- // The default User-Agent string.
- 'HTTP_USER_AGENT',
- // Header can occur on devices using Opera Mini.
- 'HTTP_X_OPERAMINI_PHONE_UA',
- // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
- 'HTTP_X_DEVICE_USER_AGENT',
- 'HTTP_X_ORIGINAL_USER_AGENT',
- 'HTTP_X_SKYFIRE_PHONE',
- 'HTTP_X_BOLT_PHONE_UA',
- 'HTTP_DEVICE_STOCK_UA',
- 'HTTP_X_UCBROWSER_DEVICE_UA'
- );
-
- /**
- * The individual segments that could exist in a User-Agent string. VER refers to the regular
- * expression defined in the constant self::VER.
- *
- * @var array
- */
- protected static $properties = array(
-
- // Build
- 'Mobile' => 'Mobile/[VER]',
- 'Build' => 'Build/[VER]',
- 'Version' => 'Version/[VER]',
- 'VendorID' => 'VendorID/[VER]',
-
- // Devices
- 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
- 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
- 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
- //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
- 'Kindle' => 'Kindle/[VER]',
-
- // Browser
- 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
- 'Coast' => array('Coast/[VER]'),
- 'Dolfin' => 'Dolfin/[VER]',
- // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
- 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
- 'Fennec' => 'Fennec/[VER]',
- // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
- // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
- 'Edge' => 'Edge/[VER]',
- 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
- // http://en.wikipedia.org/wiki/NetFront
- 'NetFront' => 'NetFront/[VER]',
- 'NokiaBrowser' => 'NokiaBrowser/[VER]',
- 'Opera' => array(' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]'),
- 'Opera Mini' => 'Opera Mini/[VER]',
- 'Opera Mobi' => 'Version/[VER]',
- 'UCBrowser' => array('UCWEB[VER]', 'UC.*Browser/[VER]'),
- 'MQQBrowser' => 'MQQBrowser/[VER]',
- 'MicroMessenger' => 'MicroMessenger/[VER]',
- 'baiduboxapp' => 'baiduboxapp/[VER]',
- 'baidubrowser' => 'baidubrowser/[VER]',
- 'SamsungBrowser' => 'SamsungBrowser/[VER]',
- 'Iron' => 'Iron/[VER]',
- // @note: Safari 7534.48.3 is actually Version 5.1.
- // @note: On BlackBerry the Version is overwriten by the OS.
- 'Safari' => array('Version/[VER]', 'Safari/[VER]'),
- 'Skyfire' => 'Skyfire/[VER]',
- 'Tizen' => 'Tizen/[VER]',
- 'Webkit' => 'webkit[ /][VER]',
- 'PaleMoon' => 'PaleMoon/[VER]',
- 'SailfishBrowser' => 'SailfishBrowser/[VER]',
-
- // Engine
- 'Gecko' => 'Gecko/[VER]',
- 'Trident' => 'Trident/[VER]',
- 'Presto' => 'Presto/[VER]',
- 'Goanna' => 'Goanna/[VER]',
-
- // OS
- 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
- 'Android' => 'Android [VER]',
- 'Sailfish' => 'Sailfish [VER]',
- 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
- 'BREW' => 'BREW [VER]',
- 'Java' => 'Java/[VER]',
- // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
- // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
- 'Windows Phone OS' => array('Windows Phone OS [VER]', 'Windows Phone [VER]'),
- 'Windows Phone' => 'Windows Phone [VER]',
- 'Windows CE' => 'Windows CE/[VER]',
- // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
- 'Windows NT' => 'Windows NT [VER]',
- 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
- 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
- );
-
- /**
- * Construct an instance of this class.
- *
- * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
- * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
- * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
- * from the $headers array instead.
- */
- public function __construct(
- array $headers = null,
- $userAgent = null
- ) {
- $this->setHttpHeaders($headers);
- $this->setUserAgent($userAgent);
- }
-
- /**
- * Get the current script version.
- * This is useful for the demo.php file,
- * so people can check on what version they are testing
- * for mobile devices.
- *
- * @return string The version number in semantic version format.
- */
- public static function getScriptVersion() {
- return self::VERSION;
- }
-
- /**
- * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
- *
- * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
- * the headers. The default null is left for backwards compatibility.
- */
- public function setHttpHeaders($httpHeaders = null) {
- // use global _SERVER if $httpHeaders aren't defined
- if (!is_array($httpHeaders) || !count($httpHeaders)) {
- $httpHeaders = $_SERVER;
- }
-
- // clear existing headers
- $this->httpHeaders = array();
-
- // Only save HTTP headers. In PHP land, that means only _SERVER vars that
- // start with HTTP_.
- foreach ($httpHeaders as $key => $value) {
- if (substr($key, 0, 5) === 'HTTP_') {
- $this->httpHeaders[$key] = $value;
- }
- }
-
- // In case we're dealing with CloudFront, we need to know.
- $this->setCfHeaders($httpHeaders);
- }
-
- /**
- * Retrieves the HTTP headers.
- *
- * @return array
- */
- public function getHttpHeaders() {
- return $this->httpHeaders;
- }
-
- /**
- * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
- * Simply null is returned.
- *
- * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
- * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
- * all-caps, HTTP_ prefixed, underscore separated awesomeness.
- *
- * @return string|null The value of the header.
- */
- public function getHttpHeader($header) {
- // are we using PHP-flavored headers?
- if (strpos($header, '_') === false) {
- $header = str_replace('-', '_', $header);
- $header = strtoupper($header);
- }
-
- // test the alternate, too
- $altHeader = 'HTTP_' . $header;
-
- //Test both the regular and the HTTP_ prefix
- if (isset($this->httpHeaders[$header])) {
- return $this->httpHeaders[$header];
- } elseif (isset($this->httpHeaders[$altHeader])) {
- return $this->httpHeaders[$altHeader];
- }
-
- return null;
- }
-
- public function getMobileHeaders() {
- return self::$mobileHeaders;
- }
-
- /**
- * Get all possible HTTP headers that
- * can contain the User-Agent string.
- *
- * @return array List of HTTP headers.
- */
- public function getUaHttpHeaders() {
- return self::$uaHttpHeaders;
- }
-
-
- /**
- * Set CloudFront headers
- * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
- *
- * @param array $cfHeaders List of HTTP headers
- *
- * @return boolean If there were CloudFront headers to be set
- */
- public function setCfHeaders($cfHeaders = null) {
- // use global _SERVER if $cfHeaders aren't defined
- if (!is_array($cfHeaders) || !count($cfHeaders)) {
- $cfHeaders = $_SERVER;
- }
-
- // clear existing headers
- $this->cloudfrontHeaders = array();
-
- // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
- // start with cloudfront-.
- $response = false;
- foreach ($cfHeaders as $key => $value) {
- if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
- $this->cloudfrontHeaders[strtoupper($key)] = $value;
- $response = true;
- }
- }
-
- return $response;
- }
-
- /**
- * Retrieves the cloudfront headers.
- *
- * @return array
- */
- public function getCfHeaders() {
- return $this->cloudfrontHeaders;
- }
-
- /**
- * @param string $userAgent
- * @return string
- */
- private function prepareUserAgent($userAgent) {
- $userAgent = trim($userAgent);
- $userAgent = substr($userAgent, 0, 500);
- return $userAgent;
- }
-
- /**
- * Set the User-Agent to be used.
- *
- * @param string $userAgent The user agent string to set.
- *
- * @return string|null
- */
- public function setUserAgent($userAgent = null) {
- // Invalidate cache due to #375
- $this->cache = array();
-
- if (false === empty($userAgent)) {
- return $this->userAgent = $this->prepareUserAgent($userAgent);
- } else {
- $this->userAgent = null;
- foreach ($this->getUaHttpHeaders() as $altHeader) {
- if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
- $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
- }
- }
-
- if (!empty($this->userAgent)) {
- return $this->userAgent = $this->prepareUserAgent($this->userAgent);
- }
- }
-
- if (count($this->getCfHeaders()) > 0) {
- return $this->userAgent = 'Amazon CloudFront';
- }
- return $this->userAgent = null;
- }
-
- /**
- * Retrieve the User-Agent.
- *
- * @return string|null The user agent if it's set.
- */
- public function getUserAgent() {
- return $this->userAgent;
- }
-
- /**
- * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
- * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
- *
- * @deprecated since version 2.6.9
- *
- * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
- * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
- */
- public function setDetectionType($type = null) {
- if ($type === null) {
- $type = self::DETECTION_TYPE_MOBILE;
- }
-
- if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
- return;
- }
-
- $this->detectionType = $type;
- }
-
- public function getMatchingRegex() {
- return $this->matchingRegex;
- }
-
- public function getMatchesArray() {
- return $this->matchesArray;
- }
-
- /**
- * Retrieve the list of known phone devices.
- *
- * @return array List of phone devices.
- */
- public static function getPhoneDevices() {
- return self::$phoneDevices;
- }
-
- /**
- * Retrieve the list of known tablet devices.
- *
- * @return array List of tablet devices.
- */
- public static function getTabletDevices() {
- return self::$tabletDevices;
- }
-
- /**
- * Alias for getBrowsers() method.
- *
- * @return array List of user agents.
- */
- public static function getUserAgents() {
- return self::getBrowsers();
- }
-
- /**
- * Retrieve the list of known browsers. Specifically, the user agents.
- *
- * @return array List of browsers / user agents.
- */
- public static function getBrowsers() {
- return self::$browsers;
- }
-
- /**
- * Retrieve the list of known utilities.
- *
- * @return array List of utilities.
- */
- public static function getUtilities() {
- return self::$utilities;
- }
-
- /**
- * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
- *
- * @deprecated since version 2.6.9
- *
- * @return array All the rules (but not extended).
- */
- public static function getMobileDetectionRules() {
- static $rules;
-
- if (!$rules) {
- $rules = array_merge(
- self::getPhoneDevices(),
- self::getTabletDevices(),
- self::getOperatingSystems(),
- self::getBrowsers()
- );
- }
-
- return $rules;
- }
-
- /**
- * Method gets the mobile detection rules + utilities.
- * The reason this is separate is because utilities rules
- * don't necessary imply mobile. This method is used inside
- * the new $detect->is('stuff') method.
- *
- * @deprecated since version 2.6.9
- *
- * @return array All the rules + extended.
- */
- public function getMobileDetectionRulesExtended() {
- static $rules;
-
- if (!$rules) {
- // Merge all rules together.
- $rules = array_merge(
- static::getPhoneDevices(),
- static::getTabletDevices(),
- static::getOperatingSystems(),
- static::getBrowsers(),
- static::getUtilities()
- );
- }
-
- return $rules;
- }
-
- /**
- * Retrieve the current set of rules.
- *
- * @deprecated since version 2.6.9
- *
- * @return array
- */
- public function getRules() {
- if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
- return self::getMobileDetectionRulesExtended();
- } else {
- return self::getMobileDetectionRules();
- }
- }
-
- /**
- * Retrieve the list of mobile operating systems.
- *
- * @return array The list of mobile operating systems.
- */
- public static function getOperatingSystems() {
- return self::$operatingSystems;
- }
-
- /**
- * Check the HTTP headers for signs of mobile.
- * This is the fastest mobile check possible; it's used
- * inside isMobile() method.
- *
- * @return bool
- */
- public function checkHttpHeadersForMobile() {
-
- foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
- if (isset($this->httpHeaders[$mobileHeader])) {
- if (isset($matchType['matches']) && is_array($matchType['matches'])) {
- foreach ($matchType['matches'] as $_match) {
- if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
- return true;
- }
- }
-
- return false;
- } else {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Magic overloading method.
- *
- * @method boolean is[...]()
- * @param string $name
- * @param array $arguments
- * @return mixed
- * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
- */
- public function __call($name, $arguments) {
- // make sure the name starts with 'is', otherwise
- if (substr($name, 0, 2) !== 'is') {
- throw new BadMethodCallException("No such method exists: $name");
- }
-
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
-
- $key = substr($name, 2);
-
- return $this->matchUAAgainstKey($key);
- }
-
- /**
- * Find a detection rule that matches the current User-agent.
- *
- * @param null $userAgent deprecated
- * @return boolean
- */
- protected function matchDetectionRulesAgainstUA($userAgent = null) {
- // Begin general search.
- foreach ($this->getRules() as $_regex) {
- if (empty($_regex)) {
- continue;
- }
-
- if ($this->match($_regex, $userAgent)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Search for a certain key in the rules array.
- * If the key is found then try to match the corresponding
- * regex against the User-Agent.
- *
- * @param string $key
- *
- * @return boolean
- */
- protected function matchUAAgainstKey($key) {
- // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
- $key = strtolower($key);
- if (false === isset($this->cache[$key])) {
-
- // change the keys to lower case
- $_rules = array_change_key_case($this->getRules());
-
- if (false === empty($_rules[$key])) {
- $this->cache[$key] = $this->match($_rules[$key]);
- }
-
- if (false === isset($this->cache[$key])) {
- $this->cache[$key] = false;
- }
- }
-
- return $this->cache[$key];
- }
-
- /**
- * Check if the device is mobile.
- * Returns true if any type of mobile device detected, including special ones
- * @param null $userAgent deprecated
- * @param null $httpHeaders deprecated
- * @return bool
- */
- public function isMobile($userAgent = null, $httpHeaders = null) {
-
- if ($httpHeaders) {
- $this->setHttpHeaders($httpHeaders);
- }
-
- if ($userAgent) {
- $this->setUserAgent($userAgent);
- }
-
- // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
- if ($this->getUserAgent() === 'Amazon CloudFront') {
- $cfHeaders = $this->getCfHeaders();
- if (array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
- return true;
- }
- }
-
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
-
- if ($this->checkHttpHeadersForMobile()) {
- return true;
- } else {
- return $this->matchDetectionRulesAgainstUA();
- }
- }
-
- /**
- * Check if the device is a tablet.
- * Return true if any type of tablet device is detected.
- *
- * @param string $userAgent deprecated
- * @param array $httpHeaders deprecated
- * @return bool
- */
- public function isTablet($userAgent = null, $httpHeaders = null) {
- // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
- if ($this->getUserAgent() === 'Amazon CloudFront') {
- $cfHeaders = $this->getCfHeaders();
- if (array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
- return true;
- }
- }
-
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
-
- foreach (static::getTabletDevices() as $_regex) {
- if ($this->match($_regex, $userAgent)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * This method checks for a certain property in the
- * userAgent.
- * @todo: The httpHeaders part is not yet used.
- *
- * @param string $key
- * @param string $userAgent deprecated
- * @param string $httpHeaders deprecated
- * @return bool|int|null
- */
- public function is($key, $userAgent = null, $httpHeaders = null) {
- // Set the UA and HTTP headers only if needed (eg. batch mode).
- if ($httpHeaders) {
- $this->setHttpHeaders($httpHeaders);
- }
-
- if ($userAgent) {
- $this->setUserAgent($userAgent);
- }
-
- $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
-
- return $this->matchUAAgainstKey($key);
- }
-
- /**
- * Some detection rules are relative (not standard),
- * because of the diversity of devices, vendors and
- * their conventions in representing the User-Agent or
- * the HTTP headers.
- *
- * This method will be used to check custom regexes against
- * the User-Agent string.
- *
- * @param $regex
- * @param string $userAgent
- * @return bool
- *
- * @todo: search in the HTTP headers too.
- */
- public function match($regex, $userAgent = null) {
- if (!\is_string($userAgent) && !\is_string($this->userAgent)) {
- return false;
- }
-
- $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : (is_string($this->userAgent) ? $this->userAgent : '')), $matches);
- // If positive match is found, store the results for debug.
- if ($match) {
- $this->matchingRegex = $regex;
- $this->matchesArray = $matches;
- }
-
- return $match;
- }
-
- /**
- * Get the properties array.
- *
- * @return array
- */
- public static function getProperties() {
- return self::$properties;
- }
-
- /**
- * Prepare the version number.
- *
- * @todo Remove the error supression from str_replace() call.
- *
- * @param string $ver The string version, like "2.6.21.2152";
- *
- * @return float
- */
- public function prepareVersionNo($ver) {
- $ver = str_replace(array('_', ' ', '/'), '.', $ver);
- $arrVer = explode('.', $ver, 2);
-
- if (isset($arrVer[1])) {
- $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
- }
-
- return (float) implode('.', $arrVer);
- }
-
- /**
- * Check the version of the given property in the User-Agent.
- * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
- *
- * @param string $propertyName The name of the property. See self::getProperties() array
- * keys for all possible properties.
- * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
- * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
- * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
- * invalid parameter will default to the this type as well.
- *
- * @return string|float|false The version of the property we are trying to extract.
- */
- public function version($propertyName, $type = self::VERSION_TYPE_STRING) {
- if (empty($propertyName)) {
- return false;
- }
-
- if (!\is_string($this->userAgent)) {
- return false;
- }
-
- // set the $type to the default if we don't recognize the type
- if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
- $type = self::VERSION_TYPE_STRING;
- }
-
- $properties = static::getProperties();
-
- // Check if the property exists in the properties array.
- if (true === isset($properties[$propertyName])) {
-
- // Prepare the pattern to be matched.
- // Make sure we always deal with an array (string is converted).
- $properties[$propertyName] = (array) $properties[$propertyName];
-
- foreach ($properties[$propertyName] as $propertyMatchString) {
-
- $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
-
- // Identify and extract the version.
- preg_match(sprintf('#%s#is', $propertyPattern), (is_string($this->userAgent) ? $this->userAgent : ''), $match);
-
- if (false === empty($match[1])) {
- $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
-
- return $version;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
- * @deprecated This is no longer being maintained, it was an experiment at the time.
- * @return string One of the self::MOBILE_GRADE_* constants.
- */
- public function mobileGrade() {
- $isMobile = $this->isMobile();
-
- if (
- // Apple iOS 4-7.0 – Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3 / 5.1 / 6.1), iPad 3 (5.1 / 6.0), iPad Mini (6.1), iPad Retina (7.0), iPhone 3GS (4.3), iPhone 4 (4.3 / 5.1), iPhone 4S (5.1 / 6.0), iPhone 5 (6.0), and iPhone 5S (7.0)
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
-
- // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
- // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
- // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
- // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
- ($this->version('Android', self::VERSION_TYPE_FLOAT) > 2.1 && $this->is('Webkit')) ||
-
- // Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8)
- $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
-
- // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
- $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
- // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
- $this->match('Playbook.*Tablet') ||
-
- // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
- ($this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi')) ||
- // Palm WebOS 3.0 - Tested on HP TouchPad
- $this->match('hp.*TouchPad') ||
-
- // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
- ($this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18) ||
-
- // Chrome for Android - Tested on Android 4.0, 4.1 device
- ($this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0) ||
-
- // Skyfire 4.1 - Tested on Android 2.3 device
- ($this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3) ||
-
- // Opera Mobile 11.5-12: Tested on Android 2.3
- ($this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS')) ||
-
- // Meego 1.2 - Tested on Nokia 950 and N9
- $this->is('MeeGoOS') ||
-
- // Sailfish OS
- $this->is('SailfishOS') ||
-
- // Tizen (pre-release) - Tested on early hardware
- $this->is('Tizen') ||
-
- // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
- // @todo: more tests here!
- $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
-
- // UC Browser - Tested on Android 2.3 device
- (($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3) ||
-
- // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
- ($this->match('Kindle Fire') ||
- $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0) ||
-
- // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
- $this->is('AndroidOS') && $this->is('NookTablet') ||
-
- // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
- $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
-
- // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
- $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
-
- // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
- $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
-
- // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
- $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
-
- // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
- $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
- ) {
- return self::MOBILE_GRADE_A;
- }
-
- if (
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) < 4.3 ||
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) < 4.3 ||
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) < 4.3 ||
-
- // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
- $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) < 6 ||
-
- //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
- ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
- ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS'))) ||
-
- // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
- $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
-
- // @todo: report this (tested on Nokia N71)
- $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
- ) {
- return self::MOBILE_GRADE_B;
- }
-
- if (
- // Blackberry 4.x - Tested on the Curve 8330
- $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
- // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
- $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
-
- // Tested on original iPhone (3.1), iPhone 3 (3.2)
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
-
- // Internet Explorer 7 and older - Tested on Windows XP
- $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
- ) {
- return self::MOBILE_GRADE_C;
- }
-
- // All older smartphone platforms and featurephones - Any device that doesn't support media queries
- // will receive the basic, C grade experience.
- return self::MOBILE_GRADE_C;
- }
-}
diff --git a/src/includes/libs/resources/attributeValueDumpers.php b/src/includes/libs/resources/attributeValueDumpers.php
deleted file mode 100644
index 59c20e6d..00000000
--- a/src/includes/libs/resources/attributeValueDumpers.php
+++ /dev/null
@@ -1,3 +0,0 @@
- 'strval', 'hexadecimal-sequence' => 'strval', 'decimal-floating-point' => 'strval', 'signed-decimal-floating-point' => 'strval', 'quoted-string' => 'function($value) {' . "\n\t" . 'return sprintf(\'"%s"\', $value);' . "\n" . '}', 'enumerated-string' => 'strval', 'decimal-resolution' => 'strval', 'datetime' => 'function($value) {' . "\n\t" . 'return sprintf(\'"%s"\', Iso8601Transformer::toString($value));' . "\n" . '}', 'byterange' => 'function($value) {' . "\n\t" . 'return sprintf(\'"%s"\', $value);' . "\n" . '}');
diff --git a/src/includes/libs/resources/attributeValueParsers.php b/src/includes/libs/resources/attributeValueParsers.php
deleted file mode 100644
index 7c4a5636..00000000
--- a/src/includes/libs/resources/attributeValueParsers.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'intval',
- 'hexadecimal-sequence' => 'strval',
- 'decimal-floating-point' => 'floatval',
- 'signed-decimal-floating-point' => 'floatval',
- 'quoted-string' => 'function($value) {' . "\n\t" . 'return trim($value, \'"\');' . "\n" . '}',
- 'enumerated-string' => 'strval',
- 'decimal-resolution' => array('Resolution', 'fromString'),
- 'datetime' => 'function($value) {' . "\n\t" . 'return Iso8601Transformer::fromString(trim($value, \'"\'));' . "\n" . '}',
- 'byterange' => 'function($value) {' . "\n\t" . 'return Byterange::fromString(trim($value, \'"\'));' . "\n" . '}'
-);
diff --git a/src/includes/libs/resources/tagValueDumpers.php b/src/includes/libs/resources/tagValueDumpers.php
deleted file mode 100644
index 4c2a4b8c..00000000
--- a/src/includes/libs/resources/tagValueDumpers.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'strval',
- 'bool' => null,
- 'enum' => null,
- 'attribute-list' => array($attributeListDumper, 'dump'),
- 'inf' => 'strval',
- 'byterange' => 'strval',
- 'datetime' => array('Iso8601Transformer', 'toString')
-);
diff --git a/src/includes/libs/resources/tagValueParsers.php b/src/includes/libs/resources/tagValueParsers.php
deleted file mode 100644
index 2b14bf3f..00000000
--- a/src/includes/libs/resources/tagValueParsers.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'intval',
- 'bool' => null,
- 'enum' => null,
- 'attribute-list' => array($attributeListParser, 'parse'),
- 'inf' => array('Inf', 'fromString'),
- 'byterange' => array('Byterange', 'fromString'),
- 'datetime' => array('Iso8601Transformer', 'fromString')
-);
diff --git a/src/includes/libs/resources/tags.php b/src/includes/libs/resources/tags.php
deleted file mode 100644
index 3d56528e..00000000
--- a/src/includes/libs/resources/tags.php
+++ /dev/null
@@ -1,64 +0,0 @@
- array('category' => 'playlist', 'type' => 'int', 'position' => -3500),
- 'EXT-X-TARGETDURATION' => array('category' => 'media-playlist', 'type' => 'int', 'position' => -2900),
- 'EXT-X-MEDIA-SEQUENCE' => array('category' => 'media-playlist', 'type' => 'int', 'position' => -2800),
- 'EXT-X-DISCONTINUITY-SEQUENCE' => array('category' => 'media-playlist', 'type' => 'int', 'position' => -2700),
- 'EXT-X-PLAYLIST-TYPE' => array('category' => 'media-playlist', 'type' => 'enum', 'position' => -2600),
- 'EXT-X-I-FRAMES-ONLY' => array('category' => 'media-playlist', 'type' => 'bool', 'position' => -2500),
- 'EXT-X-ENDLIST' => array('category' => 'media-playlist', 'type' => 'bool', 'position' => 1000),
- 'EXT-X-MEDIA' => array(
- 'category' => 'master-playlist',
- 'type' => array('TYPE' => 'enumerated-string', 'URI' => 'quoted-string', 'GROUP-ID' => 'quoted-string', 'LANGUAGE' => 'quoted-string', 'ASSOC-LANGUAGE' => 'quoted-string', 'NAME' => 'quoted-string', 'DEFAULT' => 'enumerated-string', 'AUTOSELECT' => 'enumerated-string', 'FORCED' => 'enumerated-string', 'INSTREAM-ID' => 'quoted-string', 'CHARACTERISTICS' => 'quoted-string', 'CHANNELS' => 'quoted-string'),
- 'position' => -1900,
- 'multiple' => true
- ),
- 'EXT-X-STREAM-INF' => array(
- 'category' => 'master-playlist',
- 'multiple' => true,
- 'type' => array('BANDWIDTH' => 'decimal-integer', 'AVERAGE-BANDWIDTH' => 'decimal-integer', 'CODECS' => 'quoted-string', 'RESOLUTION' => 'decimal-resolution', 'FRAME-RATE' => 'decimal-floating-point', 'HDCP-LEVEL' => 'enumerated-string', 'AUDIO' => 'quoted-string', 'VIDEO' => 'quoted-string', 'SUBTITLES' => 'quoted-string', 'CLOSED-CAPTIONS' => 'quoted-string'),
- 'position' => -1800,
- 'uriAware' => true
- ),
- 'EXT-X-I-FRAME-STREAM-INF' => array('category' => 'master-playlist', 'multiple' => true, 'position' => -1700),
- 'EXT-X-SESSION-DATA' => array(
- 'category' => 'master-playlist',
- 'type' => array('DATA-ID' => 'quoted-string', 'VALUE' => 'quoted-string', 'URI' => 'quoted-string', 'LANGUAGE' => 'quoted-string'),
- 'position' => -1600
- ),
- 'EXT-X-SESSION-KEY' => array('category' => 'master-playlist', 'position' => -1500, 'multiple' => true),
- 'EXT-X-INDEPENDENT-SEGMENTS' => array('category' => 'playlist', 'type' => 'bool', 'position' => -900),
- 'EXT-X-START' => array(
- 'category' => 'playlist',
- 'type' => array('TIME-OFFSET' => 'signed-decimal-floating-point', 'PRECISE' => 'enumerated-string'),
- 'position' => -800
- ),
- 'EXT-X-KEY' => array(
- 'category' => 'media-segment',
- 'type' => array('METHOD' => 'enumerated-string', 'URI' => 'quoted-string', 'IV' => 'hexadecimal-sequence', 'KEYFORMAT' => 'quoted-string', 'KEYFORMATVERSIONS' => 'quoted-string'),
- 'position' => 100,
- 'multiple' => true
- ),
- 'EXT-X-MAP' => array(
- 'category' => 'media-segment',
- 'type' => array('URI' => 'quoted-string', 'BYTERANGE' => 'byterange'),
- 'position' => 200
- ),
- 'EXT-X-BYTERANGE' => array('category' => 'media-segment', 'type' => 'byterange', 'position' => 300),
- 'EXT-X-DISCONTINUITY' => array('category' => 'media-segment', 'position' => 400, 'type' => 'bool'),
- 'EXT-X-PROGRAM-DATE-TIME' => array('category' => 'media-segment', 'position' => 500, 'type' => 'datetime'),
- 'EXT-X-DATERANGE' => array(
- 'category' => 'media-segment',
- 'position' => 600,
- 'type' => array('ID' => 'quoted-string', 'CLASS' => 'quoted-string', 'START-DATE' => 'datetime', 'END-DATE' => 'datetime', 'DURATION' => 'decimal-floating-point', 'PLANNED-DURATION' => 'decimal-floating-point', 'SCTE35-CMD' => 'hexadecimal-sequence', 'SCTE35-OUT' => 'hexadecimal-sequence', 'SCTE35-IN' => 'hexadecimal-sequence', 'END-ON-NEXT' => 'enumerated-string')
- ),
- 'EXTINF' => array('category' => 'media-segment', 'type' => 'inf', 'position' => 1000)
-);
-$definitions['EXT-X-I-FRAME-STREAM-INF']['type'] = $definitions['EXT-X-STREAM-INF']['type'];
-unset($definitions['EXT-X-I-FRAME-STREAM-INF']['type']['FRAME-RATE'], $definitions['EXT-X-I-FRAME-STREAM-INF']['type']['AUDIO'], $definitions['EXT-X-I-FRAME-STREAM-INF']['type']['SUBTITLES'], $definitions['EXT-X-I-FRAME-STREAM-INF']['type']['CLOSED-CAPTIONS']);
-
-$definitions['EXT-X-I-FRAME-STREAM-INF']['type']['URI'] = 'quoted-string';
-$definitions['EXT-X-SESSION-KEY']['type'] = $definitions['EXT-X-KEY']['type'];
-
-return $definitions;
diff --git a/src/includes/libs/tmdb.php b/src/includes/libs/tmdb.php
deleted file mode 100644
index bd6174de..00000000
--- a/src/includes/libs/tmdb.php
+++ /dev/null
@@ -1,810 +0,0 @@
-
- * @copyright 2012 pixelead0
- * @date 2012-02-12
- * @link http://www.github.com/pixelead
- * @version 0.0.2
- * @license BSD http://www.opensource.org/licenses/bsd-license.php
- *
- *
- * Portions of this file are based on pieces of TMDb PHP API class - API 'themoviedb.org'
- * @Copyright Jonas De Smet - Glamorous | https://github.com/glamorous/TMDb-PHP-API
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- * @date 10.12.2010
- * @version 0.9.10
- * @author Jonas De Smet - Glamorous
- * @link {https://github.com/glamorous/TMDb-PHP-API}
- *
- * Added config file + some formal corrections inside comments + some code changes to use config + (hopefully) corrected versioning
- * @Copyright Deso85 | https://github.com/deso85/tmdb_v3-PHP-API-
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- * @date 01.04.2016
- * @version 0.4
- * @author Deso85
- * @link {https://github.com/deso85/tmdb_v3-PHP-API-}
- *
- * Function List
- * public function __construct($apikey,$lang,$adult,$debug)
- * public function setLang($lang="en")
- * public function getLang()
- * public function setAdult($adult=false);
- * public function getAdult();
- * public function setDebug($debug=false);
- * public function getDebug();
- * public function setImageURL($config)
- * public function getImageURL($size="original")
- * public function movieTitles($idMovie)
- * public function movieTrans($idMovie)
- * public function movieTrailer($idMovie,$source="")
- * public function movieDetail($idMovie)
- * public function moviePoster($idMovie)
- * public function movieCast($idMovie)
- * public function movieInfo($idMovie,$option="",$print=false)
- * public function searchMovie($movieTitle)
- * public function getAPIConfig()
- * public function latestMovie()
- * public function nowPlayingMovies($page=1)
- *
- * private function _getDataArray($action,$text,$lang="")
- * private function setApikey($apikey)
- * private function getApikey()
- *
- *
- * URL LIST:
- * configuration http://api.themoviedb.org/3/configuration
- * Image http://cf2.imgobject.com/t/p/original/IMAGEN.jpg #### echar un ojo ####
- * Search Movie http://api.themoviedb.org/3/search/movie
- * Search Person http://api.themoviedb.org/3/search/person
- * Movie Info http://api.themoviedb.org/3/movie/11
- * Casts http://api.themoviedb.org/3/movie/11/casts
- * Posters http://api.themoviedb.org/3/movie/11/images
- * Trailers http://api.themoviedb.org/3/movie/11/trailers
- * translations http://api.themoviedb.org/3/movie/11/translations
- * Alternative titles http://api.themoviedb.org/3/movie/11/alternative_titles
- *
- * Collection Info http://api.themoviedb.org/3/collection/11
- * Person images http://api.themoviedb.org/3/person/287/images
- */
-class TMDB {
- public const _API_URL_ = 'http://api.themoviedb.org/3/';
- public const VERSION = '0.0.3.0';
-
- private $_config;
- private $_apikey;
- private $_lang;
- private $_adult;
- private $_apiconfiguration;
- private $_debug;
-
- /**
- * Construct Class
- * If any param is not specified, will load from config.
- *
- * @param string $apikey The API key token
- * @param string $lang The language to work with
- * @param boolean $adult The flag for adult content
- * @param boolean $debug The flag for debug output
- */
- public function __construct($apikey = null, $lang = null, $adult = null, $debug = null) {
- require __DIR__ . '/TMDb/config/config.php';
- $this->setConfig($cnf);
- $this->setApikey(isset($apikey) ? $apikey : $cnf['apikey']);
- $this->setLang(isset($lang) ? $lang : $cnf['lang']);
- $this->setAdult(isset($adult) ? $adult : $cnf['adult']);
- $this->setDebug(isset($debug) ? $debug : $cnf['debug']);
-
- if (!$this->_loadConfig()) {
- echo _('Unable to read configuration, verify that the API key is valid');
-
- exit();
- }
- }
-
- /**
- * Set configuration parameters
- *
- * @param array $config
- */
- private function setConfig($config) {
- $this->_config = $config;
- }
-
- /**
- * Get the config parameters
- *
- * @return array $config
- */
- private function getConfig() {
- return $this->_config;
- }
-
- /**
- * Set the API key
- *
- * @param string $apikey
- * @return void
- */
- private function setApikey($apikey) {
- $this->_apikey = (string) $apikey;
- }
-
- /**
- * Get the API key
- *
- * @return string
- */
- private function getApikey() {
- return $this->_apikey;
- }
-
- /**
- * Set the language
- * By default english
- *
- * @param string $lang
- */
- public function setLang($lang = 'en') {
- $this->_lang = (string) $lang;
- }
-
- /**
- * Get the language
- *
- * @return string
- */
- public function getLang() {
- return $this->_lang;
- }
-
- /**
- * Set adult content flag
- * By default false
- *
- * @param boolean $adult
- */
- public function setAdult($adult = false) {
- $this->_adult = $adult;
- }
-
- /**
- * Get the adult content flag
- *
- * @return string
- */
- public function getAdult() {
- return $this->_adult ? 'true' : 'false';
- }
-
- /**
- * Set debug mode
- * By default false
- *
- * @param boolean $debug
- */
- public function setDebug($debug = false) {
- $this->_debug = $debug;
- }
-
- /**
- * Get debug status
- *
- * @return boolean
- */
- public function getDebug() {
- return $this->_debug;
- }
-
- /**
- * Loads the configuration of the API
- *
- * @return boolean
- */
- private function _loadConfig() {
- $this->_apiconfiguration = new APIConfiguration($this->_call('configuration'));
-
- return !empty($this->_apiconfiguration);
- }
-
- /**
- * Get Configuration of the API (Revisar)
- *
- * @return Configuration
- */
- public function getAPIConfig() {
- return $this->_apiconfiguration;
- }
-
- /**
- * Get the URL images
- * You can specify the width, by default original
- *
- * @param String $size A String like 'w185' where you specify the image width
- * @return string
- */
- public function getImageURL($size = 'original') {
- return $this->_apiconfiguration->getImageBaseURL() . $size;
- }
-
- /**
- * Discover Movies
- * @add by tnsws
- *
- * @return Movie[]
- */
- public function getDiscoverMovies($page = 1) {
- $movies = array();
- $result = $this->_call('discover/movie', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Discover TVShows
- * @add by tnsws
- *
- * @return TVShow[]
- */
- public function getDiscoverTVShows($page = 1) {
- $tvShows = array();
- $result = $this->_call('discover/tv', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- /**
- * Get latest Movie
- * @add by tnsws
- *
- * @return Movie
- */
- public function getDiscoverMovie($page = 1) {
- $movies = array();
- $result = $this->_call('discover/movie', 'page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Get latest Movie
- *
- * @return Movie
- */
- public function getLatestMovie() {
- return new Movie($this->_call('movie/latest'));
- }
-
- /**
- * Get Now Playing Movies
- *
- * @param integer $page
- * @return Movie[]
- */
- public function getNowPlayingMovies($page = 1) {
- $movies = array();
- $result = $this->_call('movie/now_playing', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Get Popular Movies
- *
- * @param integer $page
- * @return Movie[]
- */
- public function getPopularMovies($page = 1) {
- $movies = array();
- $result = $this->_call('movie/popular', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Get Top Rated Movies
- * @add by tnsws
- *
- * @param integer $page
- * @return Movie[]
- */
- public function getTopRatedMovies($page = 1) {
- $movies = array();
- $result = $this->_call('movie/top_rated', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Get Upcoming Movies
- * @add by tnsws
- *
- * @param integer $page
- * @return Movie[]
- */
- public function getUpcomingMovies($page = 1) {
- $movies = array();
- $result = $this->_call('movie/upcoming', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- public function getSimilarMovies($id, $page = 1) {
- $movies = array();
- $result = $this->_call('movie/' . $id . '/similar', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Get latest TVShow
- *
- * @return TVShow
- */
- public function getLatestTVShow() {
- return new TVShow($this->_call('tv/latest'));
- }
-
- /**
- * Get On The Air TVShows
- *
- * @param integer $page
- * @return TVShow[]
- */
- public function getOnTheAirTVShows($page = 1) {
- $tvShows = array();
- $result = $this->_call('tv/on_the_air', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- public function getSimilarSeries($id, $page = 1) {
- $result = $this->_call('tv/' . $id . '/similar', '&page=' . $page);
-
- return $result['results'];
- }
-
- /**
- * Get Airing Today TVShows
- *
- * @param integer $page
- * @param string $timezone
- * @return TVShow[]
- */
- public function getAiringTodayTVShows($page = 1, $timeZone = 'Europe/Madrid') {
- $tvShows = array();
- $result = $this->_call('tv/airing_today', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- /**
- * Get Top Rated TVShows
- *
- * @param integer $page
- * @return TVShow[]
- */
- public function getTopRatedTVShows($page = 1) {
- $tvShows = array();
- $result = $this->_call('tv/top_rated', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- /**
- * Get Popular TVShows
- *
- * @param integer $page
- * @return TVShow[]
- */
- public function getPopularTVShows($page = 1) {
- $tvShows = array();
- $result = $this->_call('tv/popular', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- /**
- * Get latest Person
- *
- * @return Person
- */
- public function getLatestPerson() {
- return new Person($this->_call('person/latest'));
- }
-
- /**
- * Get Popular Persons
- *
- * @return Person[]
- */
- public function getPopularPersons($page = 1) {
- $persons = array();
- $result = $this->_call('person/popular', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $persons[] = new Person($data);
- }
-
- return $persons;
- }
-
- /**
- * Makes the call to the API and retrieves the data as a JSON
- *
- * @param string $action API specific function name for in the URL
- * @param string $appendToResponse The extra append of the request
- * @return string
- */
- private function _call($action, $appendToResponse = '') {
- $url = 'http://api.themoviedb.org/3/' . $action . '?api_key=' . $this->getApikey() . '&language=' . $this->getLang() . '&append_to_response=' . implode(',', (array) $appendToResponse) . '&include_adult=' . $this->getAdult();
-
- if ($this->_debug) {
- echo 'check request
';
- }
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FAILONERROR, 1);
- $results = curl_exec($ch);
- curl_close($ch);
-
- return (array) json_decode($results, true);
- }
-
- /**
- * Get a Movie
- *
- * @param int $idMovie The Movie id
- * @param array $appendToResponse The extra append of the request
- * @return Movie
- */
- public function getMovie($idMovie, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['movie']['default']);
-
- return new Movie($this->_call('movie/' . $idMovie, $appendToResponse));
- }
-
- public function getMovieTitles($idMovie) {
- return $this->_call('movie/' . $idMovie . '/alternative_titles');
- }
-
- public function getSeriesTitles($idTVShow) {
- return $this->_call('tv/' . $idTVShow . '/alternative_titles');
- }
-
- /**
- * Get a TVShow
- *
- * @param int $idTVShow The TVShow id
- * @param array $appendToResponse The extra append of the request
- * @return TVShow
- */
- public function getTVShow($idTVShow, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['tvshow']['default']);
-
- return new TVShow($this->_call('tv/' . $idTVShow, $appendToResponse));
- }
-
- /**
- * Get a Season
- *
- * @param int $idTVShow The TVShow id
- * @param int $numSeason The Season number
- * @param array $appendToResponse The extra append of the request
- * @return Season
- */
- public function getSeason($idTVShow, $numSeason, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['season']['default']);
-
- return new Season($this->_call('tv/' . $idTVShow . '/season/' . $numSeason, $appendToResponse), $idTVShow);
- }
-
- /**
- * Get a Episode
- *
- * @param int $idTVShow The TVShow id
- * @param int $numSeason The Season number
- * @param int $numEpisode the Episode number
- * @param array $appendToResponse The extra append of the request
- * @return Episode
- */
- public function getEpisode($idTVShow, $numSeason, $numEpisode, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['episode']['default']);
-
- return new Episode($this->_call('tv/' . $idTVShow . '/season/' . $numSeason . '/episode/' . $numEpisode, $appendToResponse), $idTVShow);
- }
-
- /**
- * Get a Person
- *
- * @param int $idPerson The Person id
- * @param array $appendToResponse The extra append of the request
- * @return Person
- */
- public function getPerson($idPerson, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['person']['default']);
-
- return new Person($this->_call('person/' . $idPerson, $appendToResponse));
- }
-
- /**
- * Get a Collection
- *
- * @param int $idCollection The Person id
- * @param array $appendToResponse The extra append of the request
- * @return Collection
- */
- public function getCollection($idCollection, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['collection']['default']);
-
- return new Collection($this->_call('collection/' . $idCollection, $appendToResponse));
- }
-
- /**
- * Get a Company
- *
- * @param int $idCompany The Person id
- * @param array $appendToResponse The extra append of the request
- * @return Company
- */
- public function getCompany($idCompany, $appendToResponse = null) {
- $appendToResponse = (isset($appendToResponse) ? $appendToResponse : $this->getConfig()['appender']['company']['default']);
-
- return new Company($this->_call('company/' . $idCompany, $appendToResponse));
- }
-
- /**
- * Search Movie
- *
- * @param string $movieTitle The title of a Movie
- * @return Movie[]
- */
- public function searchMovie($movieTitle, $rYear = null) {
- $movies = array();
- $result = $this->_call('search/movie', '&query=' . urlencode($movieTitle) . ($rYear ? '&primary_release_year=' . intval($rYear) : ''));
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-
- /**
- * Search TVShow
- *
- * @param string $tvShowTitle The title of a TVShow
- * @return TVShow[]
- */
- public function searchTVShow($tvShowTitle, $rYear = null) {
- $tvShows = array();
- $result = $this->_call('search/tv', '&query=' . urlencode($tvShowTitle) . ($rYear ? '&first_air_date_year=' . intval($rYear) : ''));
-
- foreach ($result['results'] as $data) {
- $tvShows[] = new TVShow($data);
- }
-
- return $tvShows;
- }
-
- /**
- * Search Person
- *
- * @param string $personName The name of the Person
- * @return Person[]
- */
- public function searchPerson($personName) {
- $persons = array();
- $result = $this->_call('search/person', '&query=' . urlencode($personName));
-
- foreach ($result['results'] as $data) {
- $persons[] = new Person($data);
- }
-
- return $persons;
- }
-
- /**
- * Search Collection
- *
- * @param string $collectionName The name of the Collection
- * @return Collection[]
- */
- public function searchCollection($collectionName) {
- $collections = array();
- $result = $this->_call('search/collection', '&query=' . urlencode($collectionName));
-
- foreach ($result['results'] as $data) {
- $collections[] = new Collection($data);
- }
-
- return $collections;
- }
-
- /**
- * Search Company
- *
- * @param string $companyName The name of the Company
- * @return Company[]
- */
- public function searchCompany($companyName) {
- $companies = array();
- $result = $this->_call('search/company', '&query=' . urlencode($companyName));
-
- foreach ($result['results'] as $data) {
- $companies[] = new Company($data);
- }
-
- return $companies;
- }
-
- /**
- * Find
- *
- * @param string $companyName The name of the Company
- * @return array
- */
- public function find($id, $external_source = 'imdb_id') {
- $found = array();
- $result = $this->_call('find/' . $id, '&external_source=' . urlencode($external_source));
-
- foreach ($result['movie_results'] as $data) {
- $found['movies'][] = new Movie($data);
- }
-
- foreach ($result['person_results'] as $data) {
- $found['persons'][] = new Person($data);
- }
-
- foreach ($result['tv_results'] as $data) {
- $found['tvshows'][] = new TVShow($data);
- }
-
- foreach ($result['tv_season_results'] as $data) {
- $found['seasons'][] = new Season($data);
- }
-
- foreach ($result['tv_episode_results'] as $data) {
- $found['episodes'][] = new Episode($data);
- }
-
- return $found;
- }
-
- /**
- * Get Timezones
- *
- * @return array
- */
- public function getTimezones() {
- return $this->_call('timezones/list');
- }
-
- /**
- * Get Jobs
- *
- * @return array
- */
- public function getJobs() {
- return $this->_call('job/list');
- }
-
- /**
- * Get Movie Genres
- *
- * @return Genre[]
- */
- public function getMovieGenres() {
- $genres = array();
- $result = $this->_call('genre/movie/list');
-
- foreach ($result['genres'] as $data) {
- $genres[] = new Genre($data);
- }
-
- return $genres;
- }
-
- /**
- * Get TV Genres
- *
- * @return Genre[]
- */
- public function getTVGenres() {
- $genres = array();
- $result = $this->_call('genre/tv/list');
-
- foreach ($result['genres'] as $data) {
- $genres[] = new Genre($data);
- }
-
- return $genres;
- }
-
- /**
- * Get Movies by Genre
- *
- * @param integer $idGenre
- * @param integer $page
- * @return Movie[]
- */
- public function getMoviesByGenre($idGenre, $page = 1) {
- $movies = array();
- $result = $this->_call('genre/' . $idGenre . '/movies', '&page=' . $page);
-
- foreach ($result['results'] as $data) {
- $movies[] = new Movie($data);
- }
-
- return $movies;
- }
-}
-
-include_once 'TMDb/Movie.php';
-include_once 'TMDb/TVShow.php';
-include_once 'TMDb/Season.php';
-include_once 'TMDb/Episode.php';
-include_once 'TMDb/Person.php';
-include_once 'TMDb/Role.php';
-include_once 'TMDb/roles/MovieRole.php';
-include_once 'TMDb/roles/TVShowRole.php';
-include_once 'TMDb/Collection.php';
-include_once 'TMDb/Company.php';
-include_once 'TMDb/Genre.php';
-include_once 'TMDb/config/APIConfiguration.php';
diff --git a/src/includes/libs/tmdb_release.php b/src/includes/libs/tmdb_release.php
deleted file mode 100644
index 236b7208..00000000
--- a/src/includes/libs/tmdb_release.php
+++ /dev/null
@@ -1,479 +0,0 @@
- array('cam', 'camrip', 'cam-rip', 'ts', 'telesync', 'pdvd'),
- 'TC' => array('tc', 'telecine'),
- 'DVDRip' => array('dvdrip', 'dvd-rip'),
- 'DVDScr' => array('dvdscr', 'dvd-scr', 'dvdscreener', 'screener', 'scr', 'DDC'),
- 'BDScr' => array('bluray-scr', 'bdscr'),
- 'WEB-DL' => array('webtv', 'web-tv', 'webdl', 'web-dl', 'webrip', 'web-rip', 'webhd', 'web'),
- 'BDRip' => array('bdrip', 'bd-rip', 'brrip', 'br-rip'),
- 'DVD-R' => array('dvd', 'dvdr', 'dvd-r', 'dvd-5', 'dvd-9', 'r6-dvd'),
- 'R5' => array('r5'),
- 'HDRip' => array('hdtv', 'hdtvrip', 'hdtv-rip', 'hdrip', 'hdlight', 'mhd', 'hd'),
- 'BLURAY' => array('bluray', 'blu-ray', 'bdr'),
- 'PDTV' => array('pdtv'),
- 'SDTV' => array('sdtv', 'dsr', 'dsrip', 'satrip', 'dthrip', 'dvbrip')
- );
- public static $encodingStatic = array(
- 'DivX' => array('divx'),
- 'XviD' => array('xvid'),
- 'x264' => array('x264', 'x.264'),
- 'x265' => array('x265', 'x.265'),
- 'h264' => array('h264', 'h.264')
- );
- public static $resolutionStatic = array(
- 'SD' => array('sd'),
- '720p' => array('720p'),
- '1080p' => array('1080p')
- );
- public static $dubStatic = array(
- 'DUBBED' => array('dubbed'),
- 'AC3' => array('ac3.dubbed', 'ac3'),
- 'MD' => array('md', 'microdubbed', 'micro-dubbed'),
- 'LD' => array('ld', 'linedubbed', 'line-dubbed')
- );
- public static $languageStatic = array();
- public static $flagsStatic = array(
- 'FASTSUB' => 'FASTSUB',
- 'SUBFRENCH' => 'SUBFRENCH',
- 'SUBFORCED' => 'SUBFORCED',
- 'WORKPRINT' => array('WORKPRINT', 'WP'),
- 'FANSUB' => 'FANSUB',
- 'REPACK' => 'REPACK',
- 'NFOFIX' => 'NFOFIX',
- 'INTERNAL' => array('INTERNAL', 'INT'),
- 'DOLBY DIGITAL' => 'DOLBY DIGITAL',
- 'DTS' => 'DTS',
- 'AAC' => 'AAC',
- 'DTS-HD' => 'DTS-HD',
- 'DTS-MA' => 'DTS-MA',
- 'TRUEHD' => 'TRUEHD',
- '3D' => '3D',
- 'HSBS' => 'HSBS',
- 'HOU' => 'HOU',
- 'DOC' => 'DOC',
- 'RERIP' => array('rerip', 're-rip'),
- 'DD5.1' => array('dd5.1', 'dd51', 'dd5-1', '5.1', '5-1'),
- 'READNFO' => array('READ.NFO', 'READ-NFO', 'READNFO')
- );
- protected $release;
- protected $type;
- protected $title;
- protected $year = 0;
- protected $language;
- protected $resolution;
- protected $source;
- protected $dub;
- protected $encoding;
- protected $group;
- protected $flags = array();
- protected $season = 0;
- protected $episode = 0;
-
- public function __construct($name) {
- $cleaned = $this->clean($name);
- $this->original = $name;
- $this->release = $cleaned;
- $title = $cleaned;
- $language = $this->parseLanguage($title);
- $this->setLanguage($language);
- $source = $this->parseSource($title);
- $this->setSource($source);
- $encoding = $this->parseEncoding($title);
- $this->setEncoding($encoding);
- $resolution = $this->parseResolution($title);
- $this->setResolution($resolution);
- $dub = $this->parseDub($title);
- $this->setDub($dub);
- $year = $this->parseYear($title);
- $this->setYear($year);
- $flags = $this->parseFlags($title);
- $this->setFlags($flags);
- $type = $this->parseType($title);
- $this->setType($type);
- $group = $this->parseGroup($title);
- $this->setGroup($group);
- $title = $this->parseTitle($title);
- $this->setTitle($title);
- }
-
- public function __toString() {
- $arrays = array();
-
- foreach (array($this->getTitle(), $this->getYear(), ($this->getSeason() ? 'S' . sprintf('%02d', $this->getSeason()) : '') . ($this->getEpisode() ? 'E' . sprintf('%02d', $this->getEpisode()) : ''), $this->getLanguage(), $this->getResolution(), $this->getSource(), $this->getEncoding(), $this->getDub()) as $array) {
- if (is_array($array)) {
- $arrays[] = implode('.', $array);
- } elseif ($array) {
- $arrays[] = $array;
- }
- }
-
- return preg_replace('#\\s+#', '.', implode('.', $arrays)) . '-' . ($this->getGroup() ? $this->getGroup() : 'NOTEAM');
- }
-
- public function getRelease($mode = self::ORIGINAL_RELEASE) {
- switch ($mode) {
- case 2:
- return $this->__toString();
-
- break;
-
- default:
- return $this->release;
-
- break;
- }
- }
-
- private function clean($name) {
- $release = str_replace(array('[', ']', '(', ')', ',', ';', ':', '!'), ' ', $name);
- $release = preg_replace('#[\\s]+#', ' ', $release);
- $release = str_replace(' ', '.', $release);
-
- return $release;
- }
-
- public function guess() {
- $release = $this;
-
- if (!isset($release->year)) {
- $release->setYear($release->guessYear());
- }
-
- if (!isset($release->resolution)) {
- $release->setResolution($release->guessResolution());
- }
-
- if (!isset($release->language)) {
- $release->setLanguage($release->guessLanguage());
- }
-
- return $release;
- }
-
- private function parseAttribute(&$title, $attribute) {
- if (!in_array($attribute, array('source', 'encoding', 'resolution', 'dub'))) {
- throw new InvalidArgumentException();
- }
-
- $attributes = $attribute . 'Static';
-
- foreach (Release::$$attributes as $key => $patterns) {
- if (!is_array($patterns)) {
- $patterns = array($patterns);
- }
-
- foreach ($patterns as $pattern) {
- $title = preg_replace('#[\\.|\\-]' . preg_quote($pattern) . '([\\.|\\-]|$)#i', '$1', $title, 1, $replacements);
-
- if (0 < $replacements) {
- return $key;
- }
- }
- }
-
- return null;
- }
-
- public function getType() {
- return $this->type;
- }
-
- private function parseType(&$title) {
- $type = null;
- $title = preg_replace_callback('#S(?\\d{1,2})E(?\\d{1,2})#i', function ($matches) use (&$type) {
- $type = self::TVSHOW;
- $this->setSeason(intval($matches[1]));
-
- if ($matches[2]) {
- $this->setEpisode(intval($matches[2]));
- }
-
- return $matches[3];
- }, $title, 1, $count);
-
- if ($count == 0) {
- $type = 'movie';
- }
-
- return $type;
- }
-
- public function setType($type) {
- $this->type = $type;
- }
-
- public function getTitle() {
- return trim(rtrim($this->title, '-'));
- }
-
- private function parseTitle(&$title) {
- $array = array();
- $return = '';
- $title = preg_replace('#\\.?\\-\\.#', '.', $title);
- $title = preg_replace('#\\(.*?\\)#', '', $title);
- $title = preg_replace('#\\.+#', '.', $title);
- $positions = explode('.', $this->release);
-
- foreach (array_intersect($positions, explode('.', $title)) as $key => $value) {
- $last = (isset($last) ? $last : 0);
-
- if (1 < ($key - $last)) {
- $return = implode(' ', $array);
-
- break;
- }
-
- $array[] = $value;
- $return = implode(' ', $array);
- $last = $key;
- }
-
- $return = trim($return);
-
- return $return;
- }
-
- public function setTitle($title) {
- $this->title = $title;
- }
-
- public function getSeason() {
- return $this->season;
- }
-
- public function setSeason($season) {
- $this->season = $season;
- }
-
- public function getEpisode() {
- return $this->episode;
- }
-
- public function setEpisode($episode) {
- $this->episode = $episode;
- }
-
- public function getLanguage() {
- return $this->language;
- }
-
- private function parseLanguage(&$title) {
- $languages = array();
-
- foreach (Release::$languageStatic as $langue => $patterns) {
- if (!is_array($patterns)) {
- $patterns = array($patterns);
- }
-
- foreach ($patterns as $pattern) {
- $title = preg_replace('#[\\.|\\-]' . preg_quote($pattern) . '([\\.|\\-]|$)#i', '$1', $title, 1, $replacements);
-
- if (0 < $replacements) {
- $languages[] = $langue;
-
- break;
- }
- }
- }
-
- if (count($languages) == 1) {
- return $languages[0];
- } elseif (1 < count($languages)) {
- return 'MULTI';
- } else {
- return null;
- }
- }
-
- public function guessLanguage() {
- return 'VO';
- }
-
- public function setLanguage($language) {
- $this->language = $language;
- }
-
- public function getResolution() {
- return $this->resolution;
- }
-
- private function parseResolution(&$title) {
- return $this->parseAttribute($title, 'resolution');
- }
-
- public function guessResolution() {
- if (($this->getSource() == 'BLURAY') || ($this->getSource() == 'BDScr')) {
- return '1080p';
- } else {
- return 'SD';
- }
- }
-
- public function setResolution($resolution) {
- $this->resolution = $resolution;
- }
-
- public function getSource() {
- return $this->source;
- }
-
- private function parseSource(&$title) {
- return $this->parseAttribute($title, 'source');
- }
-
- public function setSource($source) {
- $this->source = $source;
- }
-
- public function getDub() {
- return $this->dub;
- }
-
- private function parseDub(&$title) {
- return $this->parseAttribute($title, 'dub');
- }
-
- public function setDub($dub) {
- $this->dub = $dub;
- }
-
- public function getEncoding() {
- return $this->encoding;
- }
-
- private function parseEncoding(&$title) {
- return $this->parseAttribute($title, 'encoding');
- }
-
- public function setEncoding($encoding) {
- $this->encoding = $encoding;
- }
-
- public function getYear() {
- return $this->year;
- }
-
- private function parseYear(&$title) {
- $year = null;
- $title = preg_replace_callback('#[\\.|\\-|\\(|\\ ](\\d{4})([\\.|\\-|\\|\\ )])?#', function ($matches) use (&$year) {
- if (isset($matches[1])) {
- $year = $matches[1];
- }
-
- return isset($matches[2]) ? $matches[2] : '';
- }, $title, 1);
-
- return $year;
- }
-
- public function guessYear() {
- return date('Y');
- }
-
- public function setYear($year) {
- $this->year = $year;
- }
-
- public function getGroup() {
- return $this->group;
- }
-
- private function parseGroup(&$title) {
- $group = null;
- $title = preg_replace_callback('#\\-([a-zA-Z0-9_\\.]+)$#', function ($matches) use (&$group) {
- if (12 < strlen($matches[1])) {
- preg_match('#(\\w+)#', $matches[1], $matches);
- }
-
- $group = preg_replace('#^\\.+|\\.+$#', '', $matches[1]);
-
- return '';
- }, $title);
-
- return $group;
- }
-
- public function setGroup($group) {
- $this->group = $group;
- }
-
- public function getFlags() {
- return $this->flags;
- }
-
- private function parseFlags(&$title) {
- $flags = array();
-
- foreach (Release::$flagsStatic as $key => $patterns) {
- if (!is_array($patterns)) {
- $patterns = array($patterns);
- }
-
- foreach ($patterns as $pattern) {
- $title = preg_replace('#[\\.|\\-]' . preg_quote($pattern) . '([\\.|\\-]|$)#i', '$1', $title, 1, $replacements);
-
- if (0 < $replacements) {
- $flags[] = $key;
- }
- }
- }
-
- return $flags;
- }
-
- public function setFlags($flags) {
- $this->flags = (is_array($flags) ? $flags : array($flags));
- }
-
- public function getScore() {
- $score = 0;
- $score += ($this->getTitle() ? 1 : 0);
- $score += ($this->getYear() ? 1 : 0);
- $score += ($this->getLanguage() ? 1 : 0);
- $score += ($this->getResolution() ? 1 : 0);
- $score += ($this->getSource() ? 1 : 0);
- $score += ($this->getEncoding() ? 1 : 0);
- $score += ($this->getDub() ? 1 : 0);
-
- return $score;
- }
-}
diff --git a/src/includes/python/PTN/__init__.py b/src/includes/python/PTN/__init__.py
deleted file mode 100644
index 7c4ac87c..00000000
--- a/src/includes/python/PTN/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-from .parse import PTN
-
-__author__ = "Divij Bindlish"
-__email__ = "dvjbndlsh93@gmail.com"
-__version__ = "1.1.1"
-__license__ = "MIT"
-
-ptn = PTN()
-
-
-def parse(name):
- return ptn.parse(name)
diff --git a/src/includes/python/PTN/__init__.pyc b/src/includes/python/PTN/__init__.pyc
deleted file mode 100644
index c32b5a76..00000000
Binary files a/src/includes/python/PTN/__init__.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/__init__.cpython-36.pyc b/src/includes/python/PTN/__pycache__/__init__.cpython-36.pyc
deleted file mode 100644
index 934e4db5..00000000
Binary files a/src/includes/python/PTN/__pycache__/__init__.cpython-36.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/__init__.cpython-38.pyc b/src/includes/python/PTN/__pycache__/__init__.cpython-38.pyc
deleted file mode 100644
index 33f8047d..00000000
Binary files a/src/includes/python/PTN/__pycache__/__init__.cpython-38.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/parse.cpython-36.pyc b/src/includes/python/PTN/__pycache__/parse.cpython-36.pyc
deleted file mode 100644
index cb909926..00000000
Binary files a/src/includes/python/PTN/__pycache__/parse.cpython-36.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/parse.cpython-38.pyc b/src/includes/python/PTN/__pycache__/parse.cpython-38.pyc
deleted file mode 100644
index 3c9f5e61..00000000
Binary files a/src/includes/python/PTN/__pycache__/parse.cpython-38.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/patterns.cpython-36.pyc b/src/includes/python/PTN/__pycache__/patterns.cpython-36.pyc
deleted file mode 100644
index 2e4263d5..00000000
Binary files a/src/includes/python/PTN/__pycache__/patterns.cpython-36.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/__pycache__/patterns.cpython-38.pyc b/src/includes/python/PTN/__pycache__/patterns.cpython-38.pyc
deleted file mode 100644
index a043c160..00000000
Binary files a/src/includes/python/PTN/__pycache__/patterns.cpython-38.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/parse.py b/src/includes/python/PTN/parse.py
deleted file mode 100644
index f6947ca4..00000000
--- a/src/includes/python/PTN/parse.py
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import re
-from .patterns import patterns, types
-
-
-class PTN(object):
- def _escape_regex(self, string):
- return re.sub("[\-\[\]{}()*+?.,\\\^$|#\s]", "\\$&", string)
-
- def __init__(self):
- self.torrent = None
- self.excess_raw = None
- self.group_raw = None
- self.start = None
- self.end = None
- self.title_raw = None
- self.parts = None
-
- def _part(self, name, match, raw, clean):
- # The main core instructuions
- self.parts[name] = clean
-
- if len(match) != 0:
- # The instructions for extracting title
- index = self.torrent["name"].find(match[0])
- if index == 0:
- self.start = len(match[0])
- elif self.end is None or index < self.end:
- self.end = index
-
- if name != "excess":
- # The instructions for adding excess
- if name == "group":
- self.group_raw = raw
- if raw is not None:
- self.excess_raw = self.excess_raw.replace(raw, "")
-
- def _late(self, name, clean):
- if name == "group":
- self._part(name, [], None, clean)
- elif name == "episodeName":
- clean = re.sub("[\._]", " ", clean)
- clean = re.sub("_+$", "", clean)
- self._part(name, [], None, clean.strip())
-
- def parse(self, name):
- self.parts = {}
- self.torrent = {"name": name}
- self.excess_raw = name
- self.group_raw = ""
- self.start = 0
- self.end = None
- self.title_raw = None
-
- for key, pattern in patterns:
- if key not in ("season", "episode", "website"):
- pattern = r"\b%s\b" % pattern
-
- clean_name = re.sub("_", " ", self.torrent["name"])
- match = re.findall(pattern, clean_name, re.I)
- if len(match) == 0:
- continue
-
- index = {}
- if isinstance(match[0], tuple):
- match = list(match[0])
- if len(match) > 1:
- index["raw"] = 0
- index["clean"] = 1
- else:
- index["raw"] = 0
- index["clean"] = 0
-
- if key in types.keys() and types[key] == "boolean":
- clean = True
- else:
- clean = match[index["clean"]]
- if key in types.keys() and types[key] == "integer":
- clean = int(clean)
- if key == "group":
- if re.search(patterns[5][1], clean, re.I) or re.search(
- patterns[4][1], clean
- ):
- continue # Codec and quality.
- if re.match("[^ ]+ [^ ]+ .+", clean):
- key = "episodeName"
- if key == "episode":
- sub_pattern = self._escape_regex(match[index["raw"]])
- self.torrent["map"] = re.sub(
- sub_pattern, "{episode}", self.torrent["name"]
- )
- self._part(key, match, match[index["raw"]], clean)
-
- # Start process for title
- raw = self.torrent["name"]
- if self.end is not None:
- raw = raw[self.start : self.end].split("(")[0]
-
- clean = re.sub("^ -", "", raw)
- if clean.find(" ") == -1 and clean.find(".") != -1:
- clean = re.sub("\.", " ", clean)
- clean = re.sub("_", " ", clean)
- clean = re.sub("([\[\(_]|- )$", "", clean).strip()
-
- self._part("title", [], raw, clean)
-
- # Start process for end
- clean = re.sub("(^[-\. ()]+)|([-\. ]+$)", "", self.excess_raw)
- clean = re.sub("[\(\)\/]", " ", clean)
- match = re.split("\.\.+| +", clean)
- if len(match) > 0 and isinstance(match[0], tuple):
- match = list(match[0])
-
- clean = [item for item in filter(bool, match)]
- clean = [item for item in filter(lambda a: a != "-", clean)]
- if len(clean) != 0:
- group_pattern = clean[-1] + self.group_raw
- if self.torrent["name"].find(group_pattern) == len(
- self.torrent["name"]
- ) - len(group_pattern):
- self._late("group", clean.pop() + self.group_raw)
-
- if "map" in self.torrent.keys() and len(clean) != 0:
- episode_name_pattern = "{episode}" "" + re.sub("_+$", "", clean[0])
- if self.torrent["map"].find(episode_name_pattern) != -1:
- self._late("episodeName", clean.pop(0))
-
- if len(clean) != 0:
- if len(clean) == 1:
- clean = clean[0]
- self._part("excess", [], self.excess_raw, clean)
- return self.parts
diff --git a/src/includes/python/PTN/parse.pyc b/src/includes/python/PTN/parse.pyc
deleted file mode 100644
index 51c5a689..00000000
Binary files a/src/includes/python/PTN/parse.pyc and /dev/null differ
diff --git a/src/includes/python/PTN/patterns.py b/src/includes/python/PTN/patterns.py
deleted file mode 100644
index 1b4a5cb2..00000000
--- a/src/includes/python/PTN/patterns.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-patterns = [
- ("season", "(s?([0-9]{1,2}))[ex ]"),
- ("episode", "([ex]([0-9]{2})(?:[^0-9]|$))"),
- ("year", "([\[\(]?((?:19[0-9]|20[0-2])[0-9])[\]\)]?)"),
- ("resolution", "([0-9]{3,4}p)"),
- (
- "quality",
- (
- "((?:PPV\.)?[HP]DTV|(?:HD)?CAM|B[DR]Rip|TS|(?:PPV "
- ")?WEB-?DL(?: DVDRip)?|HDRip|DVDRip|DVDR"
- "IP|CamRip|W[EB]BRip|BluRay|DvDScr|hdtv)"
- ),
- ),
- ("codec", "(xvid|[hx]\.?26[45])"),
- (
- "audio",
- ("(MP3|DD5\.?1|Dual[\- ]Audio|LiNE|H?DTS|AAC(?:\.?2\.0)" "?|AC3(?:\.5\.1)?)"),
- ),
- ("group", "(- ?([^-]+(?:-={[^-]+-?$)?))$"),
- ("region", "R[0-9]"),
- ("extended", "(EXTENDED(:?.CUT)?)"),
- ("hardcoded", "HC"),
- ("proper", "PROPER"),
- ("repack", "REPACK"),
- ("container", "(MKV|AVI)"),
- ("widescreen", "WS"),
- ("website", "^(\[ ?([^\]]+?) ?\])"),
- ("language", "rus\.eng"),
- ("sbs", "(?:Half-)?SBS"),
-]
-
-types = {
- "season": "integer",
- "episode": "integer",
- "year": "integer",
- "extended": "boolean",
- "hardcoded": "boolean",
- "proper": "boolean",
- "repack": "boolean",
- "widescreen": "boolean",
-}
diff --git a/src/includes/python/PTN/patterns.pyc b/src/includes/python/PTN/patterns.pyc
deleted file mode 100644
index 8917370c..00000000
Binary files a/src/includes/python/PTN/patterns.pyc and /dev/null differ
diff --git a/src/includes/python/release.py b/src/includes/python/release.py
deleted file mode 100644
index 76d49e5f..00000000
--- a/src/includes/python/release.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import PTN, sys, json
-
-if __name__ == "__main__":
- if len(sys.argv) > 1:
- rInput = sys.argv[1]
- try:
- rJSON = json.loads(rInput)
- except:
- rJSON = None
- if rJSON:
- rOutput = {}
- for rID in rJSON:
- rOutput[rID] = PTN.parse(rJSON[rID])
- print(json.dumps(rOutput))
- else:
- print(json.dumps(PTN.parse(rInput)))
- else:
- print(json.dumps({}))
diff --git a/src/includes/reseller_api.php b/src/includes/reseller_api.php
deleted file mode 100644
index c503d324..00000000
--- a/src/includes/reseller_api.php
+++ /dev/null
@@ -1,1146 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-class ResellerAPI {
- public static $rSettings = array();
- public static $rServers = array();
- public static $rProxyServers = array();
- public static $rUserInfo = array();
- public static $rPermissions = array();
-
- public static function processData($rType, $rData) {
- $rArray = array('line' => array('edit', 'trial', 'bouquets_selected', 'pair_id', 'username', 'password', 'member_id', 'package', 'contact', 'reseller_notes', 'allowed_ips', 'allowed_ua', 'bypass_ua', 'is_isplock', 'isp_clear'), 'mag' => array('edit', 'trial', 'bouquets_selected', 'pair_id', 'mac', 'member_id', 'package', 'parent_password', 'sn', 'stb_type', 'image_version', 'hw_version', 'device_id', 'device_id2', 'ver', 'reseller_notes', 'allowed_ips', 'is_isplock', 'isp_clear'), 'enigma' => array('edit', 'trial', 'bouquets_selected', 'pair_id', 'mac', 'member_id', 'package', 'modem_mac', 'local_ip', 'enigma_version', 'cpu', 'lversion', 'token', 'reseller_notes', 'allowed_ips', 'is_isplock', 'isp_clear'), 'user' => array('edit', 'username', 'password', 'owner_id', 'email', 'reseller_dns', 'notes', 'member_group_id'), 'ticket' => array('edit', 'message', 'title', 'respond'), 'profile' => array('email', 'password', 'api_key', 'reseller_dns', 'theme', 'hue', 'timezone'));
-
- foreach ($rData as $rKey => $rValue) {
- if (in_array($rKey, $rArray[$rType])) {
- } else {
- unset($rData[$rKey]);
- }
- }
-
- return $rData;
- }
-
- public static function init($rUserID = null) {
- global $db;
- global $rPermissions;
- self::$rSettings = getSettings();
- self::$rServers = ServerRepository::getStreamingSimple($rPermissions);
- self::$rProxyServers = ServerRepository::getProxySimple($rPermissions);
-
- if ($rUserID || !isset($_SESSION['reseller'])) {
- } else {
- $rUserID = $_SESSION['reseller'];
- }
-
- if (!$rUserID) {
- } else {
- self::$rUserInfo = UserRepository::getRegisteredUserById($rUserID);
- self::$rPermissions = array_merge((getPermissions(self::$rUserInfo['member_group_id']) ?: array()), (getGroupPermissions(self::$rUserInfo['id']) ?: array()));
- }
- }
-
- public static function editResellerProfile($rData) {
- global $db;
- global $rHues;
- global $allowedLangs;
- $rData = self::processData('profile', $rData);
-
- if (0 >= strlen($rData['email']) || filter_var($rData['email'], FILTER_VALIDATE_EMAIL)) {
-
-
- if (0 < strlen($rData['password'])) {
- if (!(strlen($rData['password']) < intval(self::$rPermissions['minimum_password_length']) && 0 < intval(self::$rPermissions['minimum_password_length']))) {
- $rPassword = cryptPassword($rData['password']);
- } else {
- return array('status' => STATUS_INVALID_PASSWORD);
- }
- } else {
- $rPassword = self::$rUserInfo['password'];
- }
-
- if (ctype_xdigit($rData['api_key']) && strlen($rData['api_key']) == 32) {
- } else {
- $rData['api_key'] = '';
- }
-
- if (!in_array($rData['hue'], $rHues)) {
- $rData['hue'] = '';
- }
-
- if (!in_array($rData['theme'], array(0, 1))) {
- $rData['theme'] = 0;
- }
-
- if (!in_array($rData['lang'], $allowedLangs)) {
- $rData['lang'] = 'en';
- }
-
- $db->query('UPDATE `users` SET `password` = ?, `email` = ?, `reseller_dns` = ?, `theme` = ?, `hue` = ?, `timezone` = ?, `api_key` = ?, `lang` = ? WHERE `id` = ?;', $rPassword, $rData['email'], $rData['reseller_dns'], $rData['theme'], $rData['hue'], $rData['timezone'], $rData['api_key'], $rData['lang'], self::$rUserInfo['id']);
-
- return array('status' => STATUS_SUCCESS);
- }
-
- return array('status' => STATUS_INVALID_EMAIL);
- }
-
- public static function processLogin($rData) {
- return Authenticator::resellerLogin($rData);
- }
-
- public static function processMAG($rData) {
- global $db;
- $rData = self::processData('mag', $rData);
-
- if (self::$rPermissions['create_mag']) {
-
-
- if (isset($rData['edit'])) {
- $rArray = getMag($rData['edit']);
-
- if ($rArray && Authorization::check('line', $rArray['user_id'])) {
-
-
- $rUserArray = UserRepository::getLineById($rArray['user_id']);
- } else {
- return false;
- }
- } else {
- $rArray = verifyPostTable('mag_devices', $rData);
- $rArray['theme_type'] = self::$rSettings['mag_default_type'];
- $rUserArray = verifyPostTable('lines', $rData);
- $rUserArray['username'] = generateString(32);
- $rUserArray['password'] = generateString(32);
- $rUserArray['created_at'] = time();
- unset($rArray['mag_id'], $rUserArray['id']);
- }
-
- $rUserArray['is_mag'] = 1;
- $rUserArray['is_e2'] = 0;
- $rGenTrials = canGenerateTrials(self::$rUserInfo['id']);
-
- if (!empty($rData['package'])) {
- $rPackage = getPackage($rData['package']);
-
- if ($rPackage['is_mag']) {
-
-
- if (0 < intval($rUserArray['package_id']) && $rPackage['check_compatible']) {
- $rCompatible = checkCompatible($rUserArray['package_id'], $rPackage['id']);
- } else {
- $rCompatible = true;
- }
-
- if ($rPackage && in_array(self::$rUserInfo['member_group_id'], json_decode($rPackage['groups'], true))) {
- if ($rData['trial']) {
- if ($rGenTrials) {
- $rCost = intval($rPackage['trial_credits']);
- } else {
- return array('status' => STATUS_NO_TRIALS, 'data' => $rData);
- }
- } else {
- $rOverride = json_decode(self::$rUserInfo['override_packages'], true);
-
- if (isset($rOverride[$rPackage['id']]['official_credits']) && 0 < strlen($rOverride[$rPackage['id']]['official_credits'])) {
- $rCost = intval($rOverride[$rPackage['id']]['official_credits']);
- } else {
- $rCost = intval($rPackage['official_credits']);
- }
- }
-
- if ($rCost <= intval(self::$rUserInfo['credits'])) {
- if ($rData['trial']) {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['trial_duration']) . ' ' . $rPackage['trial_duration_in']);
- $rUserArray['is_trial'] = 1;
- } else {
- if (isset($rUserArray['id']) && $rCompatible) {
- if (time() <= $rUserArray['exp_date']) {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in'], intval($rUserArray['exp_date']));
- } else {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
- } else {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
-
- $rUserArray['is_trial'] = 0;
- }
-
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rUserArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rUserArray['bouquet'] = '[' . implode(',', array_map('intval', $rUserArray['bouquet'])) . ']';
- $rUserArray['max_connections'] = $rPackage['max_connections'];
- $rUserArray['is_restreamer'] = $rPackage['is_restreamer'];
- $rUserArray['force_server_id'] = $rPackage['force_server_id'];
- $rUserArray['forced_country'] = $rPackage['forced_country'];
- $rUserArray['is_isplock'] = $rPackage['is_isplock'];
- $rOutputs = array();
- $rAccessOutput = json_decode($rPackage['output_formats'], true);
-
- foreach ($rAccessOutput as $rOutputID) {
- $rOutputs[] = $rOutputID;
- }
- $rUserArray['allowed_outputs'] = '[' . implode(',', array_map('intval', $rOutputs)) . ']';
- $rUserArray['package_id'] = $rPackage['id'];
- $rArray['lock_device'] = $rPackage['lock_device'];
- } else {
- return array('status' => STATUS_INSUFFICIENT_CREDITS, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_TYPE, 'data' => $rData);
- }
- } else {
- if (!isset($rUserArray['id'])) {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
-
- if (!(isset($rData['edit']) && $rUserArray['package_id'])) {
- } else {
- $rPackage = getPackage($rUserArray['package_id']);
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rUserArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rUserArray['bouquet'] = '[' . implode(',', array_map('intval', $rUserArray['bouquet'])) . ']';
- }
- }
-
- foreach (array('parent_password', 'sn', 'stb_type', 'image_version', 'hw_version', 'device_id', 'device_id2', 'ver') as $rKey) {
- $rArray[$rKey] = $rData[$rKey];
- }
- $rUserArray['reseller_notes'] = $rData['reseller_notes'];
- $rOwner = $rData['member_id'];
-
- if (Authorization::check('user', $rOwner)) {
- $rUserArray['member_id'] = $rOwner;
- } else {
- $rUserArray['member_id'] = self::$rUserInfo['id'];
- }
-
- if (!self::$rPermissions['allow_restrictions']) {
- } else {
- if (isset($rData['allowed_ips'])) {
- if (is_array($rData['allowed_ips'])) {
- } else {
- $rData['allowed_ips'] = array($rData['allowed_ips']);
- }
-
- $rUserArray['allowed_ips'] = json_encode($rData['allowed_ips']);
- } else {
- $rUserArray['allowed_ips'] = '[]';
- }
-
- if (isset($rData['is_isplock'])) {
- $rUserArray['is_isplock'] = 1;
- } else {
- $rUserArray['is_isplock'] = 0;
- }
-
- if (strlen($rData['isp_clear']) != 0) {
- } else {
- $rUserArray['isp_desc'] = '';
- $rUserArray['as_number'] = null;
- }
- }
-
- if (filter_var($rData['mac'], FILTER_VALIDATE_MAC)) {
-
-
- if (isset($rData['edit'])) {
- $db->query('SELECT `mag_id` FROM `mag_devices` WHERE mac = ? AND `mag_id` <> ? LIMIT 1;', $rArray['mac'], $rData['edit']);
- } else {
- $db->query('SELECT `mag_id` FROM `mag_devices` WHERE mac = ? LIMIT 1;', $rArray['mac']);
- }
-
- if (0 >= $db->num_rows()) {
-
-
- $rArray['mac'] = $rData['mac'];
-
- if (isset($rData['pair_id']) && Authorization::check('line', $rData['pair_id'])) {
- $rUserArray['pair_id'] = intval($rData['pair_id']);
- } else {
- $rUserArray['pair_id'] = null;
- }
-
- $rPrepare = prepareArray($rUserArray);
- $rQuery = 'REPLACE INTO `lines`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if (!$db->query($rQuery, ...$rPrepare['data'])) {
- } else {
- $rInsertID = $db->last_insert_id();
- MagService::syncLineDevices($rInsertID);
- $db->query('INSERT INTO `signals`(`server_id`, `cache`, `time`, `custom_data`) VALUES(?, 1, ?, ?);', SERVER_ID, time(), json_encode(array('type' => 'update_line', 'id' => $rInsertID)));
- $rArray['user_id'] = $rInsertID;
- unset($rArray['user'], $rArray['paired']);
-
- if (isset($rData['edit'])) {
- } else {
- $rArray['ver'] = '';
- $rArray['device_id2'] = $rArray['ver'];
- $rArray['device_id'] = $rArray['device_id2'];
- $rArray['hw_version'] = $rArray['device_id'];
- $rArray['stb_type'] = $rArray['hw_version'];
- $rArray['image_version'] = $rArray['stb_type'];
- $rArray['sn'] = $rArray['image_version'];
- }
-
- $rPrepare = prepareArray($rArray);
- $rQuery = 'REPLACE INTO `mag_devices`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if ($db->query($rQuery, ...$rPrepare['data'])) {
- $rInsertID = $db->last_insert_id();
-
- if (isset($rPackage)) {
- $rNewCredits = intval(self::$rUserInfo['credits']) - intval($rCost);
- $db->query('UPDATE `users` SET `credits` = ? WHERE `id` = ?;', $rNewCredits, self::$rUserInfo['id']);
-
- if (isset($rArray['id'])) {
- if ($rUserArray['package_id']) {
- $rType = 'extend';
- } else {
- $rType = 'edit';
- }
- } else {
- $rType = 'new';
- }
-
- $rData = getMag($rInsertID);
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'mag', ?, ?, ?, ?, ?, ?, ?);", self::$rUserInfo['id'], $rType, $rInsertID, $rPackage['id'], $rCost, $rNewCredits, time(), json_encode($rData));
- } else {
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'mag', ?, ?, null, ?, ?, ?, ?);", self::$rUserInfo['id'], 'edit', $rInsertID, 0, self::$rUserInfo['credits'], time(), json_encode($rData));
- }
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rInsertID));
- }
-
- if (isset($rData['edit'])) {
- } else {
- $db->query('DELETE FROM `lines` WHERE `id` = ?;', $rInsertID);
- }
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- return array('status' => STATUS_EXISTS_MAC, 'data' => $rData);
- }
-
- return array('status' => STATUS_INVALID_MAC, 'data' => $rData);
- } else {
- return false;
- }
- }
-
- public static function processEnigma($rData) {
- global $db;
- $rData = self::processData('enigma', $rData);
-
- if (self::$rPermissions['create_enigma']) {
-
-
- if (isset($rData['edit'])) {
- $rArray = getEnigma($rData['edit']);
-
- if ($rArray && Authorization::check('line', $rArray['user_id'])) {
-
-
- $rUserArray = UserRepository::getLineById($rArray['user_id']);
- } else {
- return false;
- }
- } else {
- $rArray = verifyPostTable('enigma2_devices', $rData);
- $rUserArray = verifyPostTable('lines', $rData);
- $rUserArray['username'] = generateString(32);
- $rUserArray['password'] = generateString(32);
- $rUserArray['created_at'] = time();
- unset($rArray['device_id'], $rUserArray['id']);
- }
-
- $rUserArray['is_mag'] = 0;
- $rUserArray['is_e2'] = 1;
- $rGenTrials = canGenerateTrials(self::$rUserInfo['id']);
-
- if (!empty($rData['package'])) {
- $rPackage = getPackage($rData['package']);
-
- if ($rPackage['is_e2']) {
-
-
- if (0 < intval($rUserArray['package_id']) && $rPackage['check_compatible']) {
- $rCompatible = checkCompatible($rUserArray['package_id'], $rPackage['id']);
- } else {
- $rCompatible = true;
- }
-
- if ($rPackage && in_array(self::$rUserInfo['member_group_id'], json_decode($rPackage['groups'], true))) {
- if ($rData['trial']) {
- if ($rGenTrials) {
- $rCost = intval($rPackage['trial_credits']);
- } else {
- return array('status' => STATUS_NO_TRIALS, 'data' => $rData);
- }
- } else {
- $rOverride = json_decode(self::$rUserInfo['override_packages'], true);
-
- if (isset($rOverride[$rPackage['id']]['official_credits']) && 0 < strlen($rOverride[$rPackage['id']]['official_credits'])) {
- $rCost = intval($rOverride[$rPackage['id']]['official_credits']);
- } else {
- $rCost = intval($rPackage['official_credits']);
- }
- }
-
- if ($rCost <= intval(self::$rUserInfo['credits'])) {
- if ($rData['trial']) {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['trial_duration']) . ' ' . $rPackage['trial_duration_in']);
- $rUserArray['is_trial'] = 1;
- } else {
- if (isset($rUserArray['id']) && $rCompatible) {
- if (time() <= $rUserArray['exp_date']) {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in'], intval($rUserArray['exp_date']));
- } else {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
- } else {
- $rUserArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
-
- $rUserArray['is_trial'] = 0;
- }
-
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rUserArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rUserArray['bouquet'] = '[' . implode(',', array_map('intval', $rUserArray['bouquet'])) . ']';
- $rUserArray['max_connections'] = $rPackage['max_connections'];
- $rUserArray['is_restreamer'] = $rPackage['is_restreamer'];
- $rUserArray['force_server_id'] = $rPackage['force_server_id'];
- $rUserArray['forced_country'] = $rPackage['forced_country'];
- $rUserArray['is_isplock'] = $rPackage['is_isplock'];
- $rOutputs = array();
- $rAccessOutput = json_decode($rPackage['output_formats'], true);
-
- foreach ($rAccessOutput as $rOutputID) {
- $rOutputs[] = $rOutputID;
- }
- $rUserArray['allowed_outputs'] = '[' . implode(',', array_map('intval', $rOutputs)) . ']';
- $rUserArray['package_id'] = $rPackage['id'];
- $rArray['lock_device'] = $rPackage['lock_device'];
- } else {
- return array('status' => STATUS_INSUFFICIENT_CREDITS, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_TYPE, 'data' => $rData);
- }
- } else {
- if (!isset($rUserArray['id'])) {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
-
- if (!(isset($rData['edit']) && $rUserArray['package_id'])) {
- } else {
- $rPackage = getPackage($rUserArray['package_id']);
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rUserArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rUserArray['bouquet'] = '[' . implode(',', array_map('intval', $rUserArray['bouquet'])) . ']';
- }
- }
-
- foreach (array('modem_mac', 'local_ip', 'enigma_version', 'cpu', 'lversion', 'token') as $rKey) {
- $rArray[$rKey] = $rData[$rKey];
- }
- $rUserArray['reseller_notes'] = $rData['reseller_notes'];
- $rOwner = $rData['member_id'];
-
- if (Authorization::check('user', $rOwner)) {
- $rUserArray['member_id'] = $rOwner;
- } else {
- $rUserArray['member_id'] = self::$rUserInfo['id'];
- }
-
- if (!self::$rPermissions['allow_restrictions']) {
- } else {
- if (isset($rData['allowed_ips'])) {
- if (is_array($rData['allowed_ips'])) {
- } else {
- $rData['allowed_ips'] = array($rData['allowed_ips']);
- }
-
- $rUserArray['allowed_ips'] = json_encode($rData['allowed_ips']);
- } else {
- $rUserArray['allowed_ips'] = '[]';
- }
-
- if (isset($rData['is_isplock'])) {
- $rUserArray['is_isplock'] = 1;
- } else {
- $rUserArray['is_isplock'] = 0;
- }
-
- if (strlen($rData['isp_clear']) != 0) {
- } else {
- $rUserArray['isp_desc'] = '';
- $rUserArray['as_number'] = null;
- }
- }
-
- if (filter_var($rData['mac'], FILTER_VALIDATE_MAC)) {
-
-
- if (isset($rData['edit'])) {
- $db->query('SELECT `device_id` FROM `enigma2_devices` WHERE mac = ? AND `device_id` <> ? LIMIT 1;', $rArray['mac'], $rData['edit']);
- } else {
- $db->query('SELECT `device_id` FROM `enigma2_devices` WHERE mac = ? LIMIT 1;', $rArray['mac']);
- }
-
- if (0 >= $db->num_rows()) {
-
-
- $rArray['mac'] = $rData['mac'];
-
- if (isset($rData['pair_id']) && Authorization::check('line', $rData['pair_id'])) {
- $rUserArray['pair_id'] = intval($rData['pair_id']);
- } else {
- $rUserArray['pair_id'] = null;
- }
-
- $rPrepare = prepareArray($rUserArray);
- $rQuery = 'REPLACE INTO `lines`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if (!$db->query($rQuery, ...$rPrepare['data'])) {
- } else {
- $rInsertID = $db->last_insert_id();
- MagService::syncLineDevices($rInsertID);
- $db->query('INSERT INTO `signals`(`server_id`, `cache`, `time`, `custom_data`) VALUES(?, 1, ?, ?);', SERVER_ID, time(), json_encode(array('type' => 'update_line', 'id' => $rInsertID)));
- $rArray['user_id'] = $rInsertID;
- unset($rArray['user'], $rArray['paired']);
-
- if (isset($rData['edit'])) {
- } else {
- $rArray['token'] = '';
- $rArray['lversion'] = $rArray['token'];
- $rArray['cpu'] = $rArray['lversion'];
- $rArray['enigma_version'] = $rArray['cpu'];
- $rArray['local_ip'] = $rArray['enigma_version'];
- $rArray['modem_mac'] = $rArray['local_ip'];
- }
-
- $rPrepare = prepareArray($rArray);
- $rQuery = 'REPLACE INTO `enigma2_devices`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if ($db->query($rQuery, ...$rPrepare['data'])) {
- $rInsertID = $db->last_insert_id();
-
- if (isset($rPackage)) {
- $rNewCredits = intval(self::$rUserInfo['credits']) - intval($rCost);
- $db->query('UPDATE `users` SET `credits` = ? WHERE `id` = ?;', $rNewCredits, self::$rUserInfo['id']);
-
- if (isset($rArray['id'])) {
- if ($rArray['package_id']) {
- $rType = 'extend';
- } else {
- $rType = 'edit';
- }
- } else {
- $rType = 'new';
- }
-
- $rData = getEnigma($rInsertID);
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'enigma', ?, ?, ?, ?, ?, ?, ?);", self::$rUserInfo['id'], $rType, $rInsertID, $rPackage['id'], $rCost, $rNewCredits, time(), json_encode($rData));
- } else {
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'enigma', ?, ?, null, ?, ?, ?, ?);", self::$rUserInfo['id'], 'edit', $rInsertID, 0, self::$rUserInfo['credits'], time(), json_encode($rData));
- }
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rInsertID));
- }
-
- if (isset($rData['edit'])) {
- } else {
- $db->query('DELETE FROM `lines` WHERE `id` = ?;', $rInsertID);
- }
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- return array('status' => STATUS_EXISTS_MAC, 'data' => $rData);
- }
-
- return array('status' => STATUS_INVALID_MAC, 'data' => $rData);
- } else {
- return false;
- }
- }
-
- public static function processUser($rData) {
- global $db;
- $rData = self::processData('user', $rData);
-
- if (self::$rPermissions['create_sub_resellers']) {
-
-
- if (isset($rData['edit'])) {
- $rArray = UserRepository::getRegisteredUserById($rData['edit']);
-
- if ($rArray && Authorization::check('user', $rArray['id'])) {
-
-
- if ($rArray['id'] != self::$rUserInfo['id']) {
- } else {
- return false;
- }
- } else {
- return false;
- }
- } else {
- $rArray = verifyPostTable('users', $rData);
- $rArray['date_registered'] = time();
- unset($rArray['id']);
- }
-
- if (self::$rPermissions['allow_change_username']) {
- } else {
- if (isset($rArray['id'])) {
- $rData['username'] = $rArray['username'];
- } else {
- $rData['username'] = generateString((10 < self::$rPermissions['minimum_username_length'] ? self::$rPermissions['minimum_username_length'] : 10));
- }
- }
-
- if (self::$rPermissions['allow_change_password']) {
- } else {
- if (isset($rArray['id'])) {
- $rData['password'] = '';
- } else {
- $rData['password'] = generateString((10 < self::$rPermissions['minimum_password_length'] ? self::$rPermissions['minimum_password_length'] : 10));
- }
- }
-
- if (strlen($rData['username']) >= self::$rPermissions['minimum_username_length'] || (isset($rData['edit']) && strlen($rData['username']) == 0)) {
-
-
- if (strlen($rData['password']) >= self::$rPermissions['minimum_password_length'] || (isset($rData['edit']) && strlen($rData['password']) == 0)) {
-
-
- if (!checkExists('users', 'username', $rArray['username'], 'id', $rData['edit'])) {
-
-
- $rArray['username'] = $rData['username'];
-
- if (0 >= strlen($rData['password'])) {
- } else {
- $rArray['password'] = cryptPassword($rData['password']);
- }
-
- if (0 < count(self::$rPermissions['all_reports']) && in_array(intval($rData['owner_id']), self::$rPermissions['all_reports']) && (!isset($rArray['id']) || $rArray['id'] != $rData['owner_id'])) {
- $rArray['owner_id'] = intval($rData['owner_id']);
- } else {
- $rArray['owner_id'] = self::$rUserInfo['id'];
- }
-
- if (isset($rData['edit'])) {
- } else {
- $rCost = intval(self::$rPermissions['create_sub_resellers_price']);
-
- if (self::$rUserInfo['credits'] - $rCost >= 0) {
- } else {
- return array('status' => STATUS_INSUFFICIENT_CREDITS, 'data' => $rData);
- }
- }
-
- if (isset($rData['member_group_id']) && in_array($rData['member_group_id'], self::$rPermissions['subresellers'])) {
- $rArray['member_group_id'] = $rData['member_group_id'];
- } else {
- if (0 < count(self::$rPermissions['subresellers'])) {
- $rArray['member_group_id'] = self::$rPermissions['subresellers'][0];
- } else {
- return array('status' => STATUS_INVALID_SUBRESELLER, 'data' => $rData);
- }
- }
-
- $rArray['email'] = $rData['email'];
- $rArray['reseller_dns'] = $rData['reseller_dns'];
- $rArray['notes'] = $rData['notes'];
- $rPrepare = prepareArray($rArray);
- $rQuery = 'REPLACE INTO `users`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if ($db->query($rQuery, ...$rPrepare['data'])) {
- $rInsertID = $db->last_insert_id();
- $rData = UserRepository::getRegisteredUserById($rInsertID);
-
- if (isset($rCost)) {
- $rNewCredits = intval(self::$rUserInfo['credits']) - intval($rCost);
- $db->query('UPDATE `users` SET `credits` = ? WHERE `id` = ?;', $rNewCredits, self::$rUserInfo['id']);
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'user', ?, ?, null, ?, ?, ?, ?);", self::$rUserInfo['id'], 'new', $rInsertID, $rCost, $rNewCredits, time(), json_encode($rData));
- } else {
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'user', ?, ?, null, ?, ?, ?, ?);", self::$rUserInfo['id'], 'edit', $rInsertID, 0, self::$rUserInfo['credits'], time(), json_encode($rData));
- }
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rInsertID));
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- return array('status' => STATUS_EXISTS_USERNAME, 'data' => $rData);
- }
-
- return array('status' => STATUS_INVALID_PASSWORD, 'data' => $rData);
- }
-
- return array('status' => STATUS_INVALID_USERNAME, 'data' => $rData);
- }
-
- return false;
- }
-
- public static function submitTicket($rData) {
- global $db;
- $rData = self::processData('ticket', $rData);
-
- if (isset($rData['edit'])) {
- $rArray = getTicket($rData['edit']);
-
- if ($rArray && Authorization::check('user', $rArray['member_id'])) {
- } else {
- return false;
- }
- } else {
- $rArray = verifyPostTable('tickets', $rData);
- unset($rArray['id']);
- }
-
- if (!(strlen($rData['title']) == 0 && !isset($rData['respond']) || strlen($rData['message']) == 0)) {
-
-
-
- $rArray['member_id'] = self::$rUserInfo['id'];
-
- if (!isset($rData['respond'])) {
- $rArray['title'] = $rData['title'];
- $rArray['status'] = 1;
- $rArray['admin_read'] = 0;
- $rArray['user_read'] = 0;
- $rPrepare = prepareArray($rArray);
- $rQuery = 'REPLACE INTO `tickets`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if ($db->query($rQuery, ...$rPrepare['data'])) {
- $rInsertID = $db->last_insert_id();
- $db->query('INSERT INTO `tickets_replies`(`ticket_id`, `admin_reply`, `message`, `date`) VALUES(?, 0, ?, ?);', $rInsertID, $rData['message'], time());
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rInsertID));
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- $rTicket = getTicket($rData['respond']);
-
- if ($rTicket) {
- if (intval(self::$rUserInfo['id']) == intval($rTicket['member_id'])) {
- $db->query('UPDATE `tickets` SET `admin_read` = 0, `user_read` = 1 WHERE `id` = ?;', $rData['respond']);
- $db->query('INSERT INTO `tickets_replies`(`ticket_id`, `admin_reply`, `message`, `date`) VALUES(?, 0, ?, ?);', $rData['respond'], $rData['message'], time());
- } else {
- $db->query('UPDATE `tickets` SET `admin_read` = 0, `user_read` = 0 WHERE `id` = ?;', $rData['respond']);
- $db->query('INSERT INTO `tickets_replies`(`ticket_id`, `admin_reply`, `message`, `date`) VALUES(?, 1, ?, ?);', $rData['respond'], $rData['message'], time());
- }
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rData['respond']));
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- return array('status' => STATUS_INVALID_DATA, 'data' => $rData);
- }
-
- public static function processLine($rData) {
- global $db;
- $rData = self::processData('line', $rData);
-
- if (self::$rPermissions['create_line']) {
-
-
- if (isset($rData['edit'])) {
- $rArray = UserRepository::getLineById($rData['edit']);
- $rOrigCredentials = array('username' => $rArray['username'], 'password' => $rArray['password']);
-
- if ($rArray && Authorization::check('line', $rArray['id'])) {
- } else {
- return false;
- }
- } else {
- $rArray = verifyPostTable('lines', $rData);
- $rArray['created_at'] = time();
- unset($rArray['id']);
- }
-
- $rArray['is_mag'] = 0;
- $rArray['is_e2'] = 0;
- $rGenTrials = canGenerateTrials(self::$rUserInfo['id']);
-
- if (!empty($rData['package'])) {
- $rPackage = getPackage($rData['package']);
-
- if ($rPackage['is_line']) {
-
-
- if (0 < intval($rArray['package_id']) && $rPackage['check_compatible']) {
- $rCompatible = checkCompatible($rArray['package_id'], $rPackage['id']);
- } else {
- $rCompatible = true;
- }
-
- if ($rPackage && in_array(self::$rUserInfo['member_group_id'], json_decode($rPackage['groups'], true))) {
- if ($rData['trial']) {
- if ($rGenTrials) {
- $rCost = intval($rPackage['trial_credits']);
- } else {
- return array('status' => STATUS_NO_TRIALS, 'data' => $rData);
- }
- } else {
- $rOverride = json_decode(self::$rUserInfo['override_packages'], true);
-
- if (isset($rOverride[$rPackage['id']]['official_credits']) && 0 < strlen($rOverride[$rPackage['id']]['official_credits'])) {
- $rCost = intval($rOverride[$rPackage['id']]['official_credits']);
- } else {
- $rCost = intval($rPackage['official_credits']);
- }
- }
-
- if ($rCost <= intval(self::$rUserInfo['credits'])) {
- if ($rData['trial']) {
- $rArray['exp_date'] = strtotime('+' . intval($rPackage['trial_duration']) . ' ' . $rPackage['trial_duration_in']);
- $rArray['is_trial'] = 1;
- } else {
- if (isset($rArray['id']) && $rCompatible) {
- if (time() <= $rArray['exp_date']) {
- $rArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in'], intval($rArray['exp_date']));
- } else {
- $rArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
- } else {
- $rArray['exp_date'] = strtotime('+' . intval($rPackage['official_duration']) . ' ' . $rPackage['official_duration_in']);
- }
-
- $rArray['is_trial'] = 0;
- }
-
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rArray['bouquet'] = '[' . implode(',', array_map('intval', $rArray['bouquet'])) . ']';
- $rArray['max_connections'] = $rPackage['max_connections'];
- $rArray['is_restreamer'] = $rPackage['is_restreamer'];
- $rArray['force_server_id'] = $rPackage['force_server_id'];
- $rArray['forced_country'] = $rPackage['forced_country'];
- $rArray['is_isplock'] = $rPackage['is_isplock'];
- $rArray['package_id'] = $rPackage['id'];
- } else {
- return array('status' => STATUS_INSUFFICIENT_CREDITS, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
- } else {
- return array('status' => STATUS_INVALID_TYPE, 'data' => $rData);
- }
- } else {
- if (!isset($rArray['id'])) {
- return array('status' => STATUS_INVALID_PACKAGE, 'data' => $rData);
- }
-
- if (!(isset($rData['edit']) && $rArray['package_id'])) {
- } else {
- $rPackage = getPackage($rArray['package_id']);
- $rBouquets = array_values(json_decode($rPackage['bouquets'], true));
-
- if (!(self::$rPermissions['allow_change_bouquets'] && 0 < count($rData['bouquets_selected'] ?? []))) {
- } else {
- $rNewBouquets = array();
-
- foreach ($rData['bouquets_selected'] as $rBouquetID) {
- if (!in_array($rBouquetID, $rBouquets)) {
- } else {
- $rNewBouquets[] = $rBouquetID;
- }
- }
-
- if (0 >= count($rNewBouquets)) {
- } else {
- $rBouquets = $rNewBouquets;
- }
- }
-
- $rArray['bouquet'] = sortArrayByArray($rBouquets, array_keys(BouquetService::getOrder()));
- $rArray['bouquet'] = '[' . implode(',', array_map('intval', $rArray['bouquet'])) . ']';
- }
- }
-
- $rArray['contact'] = $rData['contact'];
- $rArray['reseller_notes'] = $rData['reseller_notes'];
- $rOwner = $rData['member_id'];
-
- if (Authorization::check('user', $rOwner)) {
- $rArray['member_id'] = $rOwner;
- } else {
- $rArray['member_id'] = self::$rUserInfo['id'];
- }
-
- if (self::$rPermissions['allow_change_username']) {
- } else {
- if (isset($rArray['id'])) {
- $rData['username'] = $rArray['username'];
- } else {
- $rData['username'] = '';
- }
- }
-
- if (self::$rPermissions['allow_change_password']) {
- } else {
- if (isset($rArray['id'])) {
- $rData['password'] = $rArray['password'];
- } else {
- $rData['password'] = '';
- }
- }
-
- if (strlen($rData['username']) == 0) {
- if (!isset($rData['edit'])) {
- $rData['username'] = generateString((10 < self::$rPermissions['minimum_username_length'] ? self::$rPermissions['minimum_username_length'] : 10));
- } else {
- $rData['username'] = $rArray['username'];
- }
- } else {
- if (strlen($rData['username']) >= self::$rPermissions['minimum_username_length']) {
- } else {
- if (isset($rData['edit']) && $rData['username'] == $rOrigCredentials['username']) {
- } else {
- return array('status' => STATUS_INVALID_USERNAME, 'data' => $rData);
- }
- }
- }
-
- if (strlen($rData['password']) == 0) {
- if (!isset($rData['edit'])) {
- $rData['password'] = generateString((10 < self::$rPermissions['minimum_password_length'] ? self::$rPermissions['minimum_password_length'] : 10));
- } else {
- $rData['password'] = $rArray['password'];
- }
- } else {
- if (strlen($rData['password']) >= self::$rPermissions['minimum_password_length']) {
- } else {
- if (isset($rData['edit']) && $rData['password'] == $rOrigCredentials['password']) {
- } else {
- return array('status' => STATUS_INVALID_PASSWORD, 'data' => $rData);
- }
- }
- }
-
- if (empty($rData['username'])) {
- } else {
- $rArray['username'] = $rData['username'];
- }
-
- if (empty($rData['password'])) {
- } else {
- $rArray['password'] = $rData['password'];
- }
-
- if (!checkExists('lines', 'username', $rArray['username'], 'id', $rData['edit'])) {
-
-
- if (!self::$rPermissions['allow_restrictions']) {
- } else {
- if (isset($rData['allowed_ips'])) {
- if (is_array($rData['allowed_ips'])) {
- } else {
- $rData['allowed_ips'] = array($rData['allowed_ips']);
- }
-
- $rArray['allowed_ips'] = json_encode($rData['allowed_ips']);
- } else {
- $rArray['allowed_ips'] = '[]';
- }
-
- if (isset($rData['allowed_ua'])) {
- if (is_array($rData['allowed_ua'])) {
- } else {
- $rData['allowed_ua'] = array($rData['allowed_ua']);
- }
-
- $rArray['allowed_ua'] = json_encode($rData['allowed_ua']);
- } else {
- $rArray['allowed_ua'] = '[]';
- }
-
- if (isset($rData['bypass_ua'])) {
- $rArray['bypass_ua'] = 1;
- } else {
- $rArray['bypass_ua'] = 0;
- }
-
- if (isset($rData['is_isplock'])) {
- $rArray['is_isplock'] = 1;
- } else {
- $rArray['is_isplock'] = 0;
- }
-
- if (strlen($rData['isp_clear']) != 0) {
- } else {
- $rArray['isp_desc'] = '';
- $rArray['as_number'] = null;
- }
- }
-
- if (!isset($rPackage)) {
- } else {
- $rOutputs = array();
- $rAccessOutput = json_decode($rPackage['output_formats'], true);
-
- foreach ($rAccessOutput as $rOutputID) {
- $rOutputs[] = $rOutputID;
- }
- $rArray['allowed_outputs'] = '[' . implode(',', array_map('intval', $rOutputs)) . ']';
- }
-
- $rPrepare = prepareArray($rArray);
- $rQuery = 'REPLACE INTO `lines`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
-
- if ($db->query($rQuery, ...$rPrepare['data'])) {
- $rInsertID = $db->last_insert_id();
- MagService::syncLineDevices($rInsertID);
- if (isset($rPackage)) {
- $rNewCredits = intval(self::$rUserInfo['credits']) - intval($rCost);
- $db->query('UPDATE `users` SET `credits` = ? WHERE `id` = ?;', $rNewCredits, self::$rUserInfo['id']);
-
- if (isset($rArray['id'])) {
- if ($rArray['package_id']) {
- $rType = 'extend';
- } else {
- $rType = 'edit';
- }
- } else {
- $rType = 'new';
- }
-
- $rData = UserRepository::getLineById($rInsertID);
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'line', ?, ?, ?, ?, ?, ?, ?);", self::$rUserInfo['id'], $rType, $rInsertID, $rPackage['id'], $rCost, $rNewCredits, time(), json_encode($rData));
- } else {
- $db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'line', ?, ?, null, ?, ?, ?, ?);", self::$rUserInfo['id'], 'edit', $rInsertID, 0, self::$rUserInfo['credits'], time(), json_encode($rData));
- }
-
- return array('status' => STATUS_SUCCESS, 'data' => array('insert_id' => $rInsertID));
- }
-
- return array('status' => STATUS_FAILURE, 'data' => $rData);
- }
-
- return array('status' => STATUS_EXISTS_USERNAME, 'data' => $rData);
- }
-
- return false;
- }
-}
diff --git a/src/includes/ts.php b/src/includes/ts.php
deleted file mode 100644
index 475f60b4..00000000
--- a/src/includes/ts.php
+++ /dev/null
@@ -1,143 +0,0 @@
-
- * @copyright 2025-2026 Vateron Media
- * @link https://github.com/Vateron-Media/XC_VM
- * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
- */
-
-class TS {
- public static $rBuffer = null;
- public static $rPosition = null;
- public static $rByte = null;
- public static $rIndex = null;
-
- public function setPacket($rBuffer) {
- self::$rBuffer = $rBuffer;
- self::$rPosition = 7;
- list(self::$rByte) = array_values(unpack('C', self::$rBuffer[0]));
- self::$rIndex = 1;
- }
-
- public function getBits($rNumBits) {
- $rNum = 0;
- $rMask = 1 << self::$rPosition;
-
- while (0 < $rNumBits) {
- $rNumBits -= 1;
- $rNum <<= 1;
-
- if (!(self::$rByte & $rMask)) {
- $rMask >>= 1;
-
-
- self::$rPosition -= 1;
-
- if (self::$rPosition < 0) {
- self::$rPosition = 7;
- $rMask = 1 << self::$rPosition;
-
- if (self::$rIndex < strlen(self::$rBuffer)) {
- list(self::$rByte) = array_values(unpack('C', self::$rBuffer[self::$rIndex]));
- } else {
- self::$rByte = 0;
- }
- }
- } else {
- $rNum |= 1;
- }
-
- self::$rIndex += 1;
- }
-
- return $rNum;
- }
-
- public function parsePacket() {
- $rReturn = array('sync_byte' => self::getBits(8), 'transport_error_indicator' => self::getBits(1), 'payload_unit_start_indicator' => self::getBits(1), 'transport_priority' => self::getBits(1), 'pid' => self::getBits(13), 'scrambling_control' => self::getBits(2), 'adaptation_field_exist' => self::getBits(2), 'continuity_counter' => self::getBits(4));
-
- if (($rReturn['adaptation_field_exist'] || $rReturn['adaptation_field_exist'] == 3)) {
- $rTell = self::$rIndex;
- $rReturn['adaptation_field_length'] = self::getBits(8);
-
- if ($rReturn['adaptation_field_length'] == 7) {
- $rReturn = array_merge($rReturn, array('discontinuity_indicator' => self::getBits(1), 'random_access_indicator' => self::getBits(1), 'priority_indicator' => self::getBits(1), 'pcr_flag' => self::getBits(1), 'opcr_flag' => self::getBits(1), 'splicing_point_flag' => self::getBits(1), 'transport_private_data_flag' => self::getBits(1), 'adaptation_field_extension_flag' => self::getBits(1)));
-
- if ($rReturn['pcr_flag']) {
- $rReturn = array_merge($rReturn, array('program_clock_reference_base' => self::getBits(33), 'reserved_pcr' => self::getBits(6), 'program_clock_reference_extension' => self::getBits(9)));
- $rReturn['pcr'] = ($rReturn['program_clock_reference_base'] * 300 + $rReturn['program_clock_reference_extension']) / 27000000;
- }
-
- if ($rReturn['opcr_flag']) {
- $rReturn = array_merge($rReturn, array('original_program_clock_reference_base' => self::getBits(33), 'reserved_opcr' => self::getBits(6), 'original_program_clock_reference_extension' => self::getBits(9)));
- $rReturn['opcr'] = ($rReturn['original_program_clock_reference_base'] * 300 + $rReturn['original_program_clock_reference_extension']) / 27000000;
- }
-
- if ($rReturn['splicing_point_flag']) {
- $rReturn['splice_countdown'] = self::getBits(8);
- }
-
- if ($rReturn['transport_private_data_flag']) {
- $rReturn['transport_private_data_length'] = self::getBits(8);
- self::stepBytes($rReturn['transport_private_data_length']);
- }
- } else {
- unset($rReturn['adaptation_field_length']);
- }
- }
-
- if ($rReturn['pid'] == 0) {
- $rReturn['pointer_field'] = self::getBits(8);
-
- if ($rReturn['pointer_field']) {
- self::stepBytes($rReturn['pointer_field']);
- }
-
- $rReturn = array_merge($rReturn, array('type' => 'pat', 'table_id' => self::getBits(8), 'section_syntax_indicator' => self::getBits(1), 'marker' => self::getBits(1), 'reserved_1' => self::getBits(2), 'section_length' => self::getBits(12), 'transport_stream_id' => self::getBits(16), 'reserved_2' => self::getBits(2), 'version_number' => self::getBits(5), 'current_next_indicator' => self::getBits(1), 'section_number' => self::getBits(8), 'last_section_number' => self::getBits(8)));
- } else {
- if ($rReturn['payload_unit_start_indicator']) {
- self::$rBuffer = substr(self::$rBuffer, self::$rIndex, 188);
- self::$rIndex = 0;
- $rReturn = array_merge($rReturn, array('type' => 'pes', 'packet_start_prefix' => self::getBits(24), 'stream_id' => self::getBits(8), 'pes_packet_length' => self::getBits(16), 'marker_bits' => self::getBits(2), 'scrambling_control' => self::getBits(2), 'priority' => self::getBits(1), 'data_alignment_indicator' => self::getBits(1), 'copyright' => self::getBits(1), 'original_or_copy' => self::getBits(1), 'pts_dts_indicator' => self::getBits(2), 'escr_flag' => self::getBits(1), 'es_rate_flag' => self::getBits(1), 'dsm_trick_mode_flag' => self::getBits(1), 'additional_copy_info_flag' => self::getBits(1), 'crc_flag' => self::getBits(1), 'extension_flag' => self::getBits(1), 'pes_header_length' => self::getBits(8)));
-
- if (($rReturn['pts_dts_indicator'] == 2 || $rReturn['pts_dts_indicator'] == 3)) {
- self::getBits(4);
- $rPTSA = self::getBits(3);
- self::getBits(1);
- $rPTSB = self::getBits(15);
- self::getBits(1);
- $rPTSC = self::getBits(15);
- self::getBits(1);
- $rReturn['pts'] = ($rPTSA << 30) + ($rPTSB << 15) + $rPTSC;
- }
-
- if ($rReturn['pts_dts_indicator'] == 3) {
- self::getBits(4);
- $rDTSA = self::getBits(3);
- self::getBits(1);
- $rDTSB = self::getBits(15);
- self::getBits(1);
- $rDTSC = self::getBits(15);
- self::getBits(1);
- $rReturn['dts'] = ($rDTSA << 30) + ($rDTSB << 15) + $rDTSC;
- }
- }
- }
-
- return $rReturn;
- }
-
- public function stepBytes($rBytes) {
- $rData = substr(self::$rBuffer, self::$rIndex - 1, $rBytes);
-
- foreach (range(0, $rBytes) as $i) {
- self::getBits(8);
- }
-
- return $rData;
- }
-}
diff --git a/src/infrastructure/bootstrap/admin_functions_fc.php b/src/infrastructure/bootstrap/admin_functions_fc.php
index 8fa635e7..48ea0abc 100644
--- a/src/infrastructure/bootstrap/admin_functions_fc.php
+++ b/src/infrastructure/bootstrap/admin_functions_fc.php
@@ -29,7 +29,8 @@ global $db, $rSettings, $rMobile, $rServers, $rProxyServers, $rDetect,
$rTimeout, $rProtocol, $allServers, $rPermissions, $language, $allowedLangs,
$rServerError, $allServersHealthy, $updateRequired, $rUserInfo, $_INFO;
-require_once MAIN_HOME . 'includes/admin.php';
+require_once MAIN_HOME . 'bootstrap.php';
+XC_Bootstrap::boot(XC_Bootstrap::CONTEXT_ADMIN);
if ($rMobile) {
$rSettings['js_navigate'] = 0;
@@ -54,7 +55,7 @@ if (isset($_SESSION['hash'])) {
$language::setLanguage($rUserInfo['lang']);
}
- $rPermissions = getPermissions($rUserInfo['member_group_id']);
+ $rPermissions = AuthRepository::getPermissions($rUserInfo['member_group_id']);
$rPermissions['advanced'] = json_decode($rPermissions['allowed_pages'], true);
$rIP = NetworkUtils::getUserIP();
$rIPMatch = ($rSettings['ip_subnet_match'] ? implode('.', array_slice(explode('.', $_SESSION['ip']), 0, -1)) == implode('.', array_slice(explode('.', $rIP), 0, -1)) : $_SESSION['ip'] == $rIP);
@@ -62,7 +63,7 @@ if (isset($_SESSION['hash'])) {
if (!$rUserInfo || !$rPermissions || !$rPermissions['is_admin'] || !$rIPMatch && $rSettings['ip_logout'] || $_SESSION['verify'] != md5($rUserInfo['username'] . '||' . $rUserInfo['password'])) {
unset($rUserInfo, $rPermissions);
- destroySession();
+ SessionManager::clearContext('admin');
header('Location: index');
exit();
@@ -98,10 +99,10 @@ if (isset(RequestManager::getAll()['status'])) {
$_STATUS = intval(RequestManager::getAll()['status']);
$rArgs = RequestManager::getAll();
unset($rArgs['status']);
- $customScript = setArgs($rArgs);
+ $customScript = AdminHelpers::setArgs($rArgs);
}
-if (getPageName() != 'setup') {
+if (AdminHelpers::getPageName() != 'setup') {
$db->query('SELECT COUNT(`id`) AS `count` FROM `users` LEFT JOIN `users_groups` ON `users_groups`.`group_id` = `users`.`member_group_id` WHERE `users_groups`.`is_admin` = 1;');
if ($db->get_row()['count'] == 0) {
diff --git a/src/infrastructure/bootstrap/player_functions.php b/src/infrastructure/bootstrap/player_functions.php
index 21f12061..448d4bb8 100644
--- a/src/infrastructure/bootstrap/player_functions.php
+++ b/src/infrastructure/bootstrap/player_functions.php
@@ -23,8 +23,9 @@ if (!defined('MAIN_HOME')) {
define('MAIN_HOME', dirname(__DIR__, 2) . '/');
}
-require_once MAIN_HOME . 'includes/admin.php';
-require_once INCLUDES_PATH . 'libs/tmdb.php';
+require_once MAIN_HOME . 'bootstrap.php';
+XC_Bootstrap::boot(XC_Bootstrap::CONTEXT_ADMIN);
+require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
if (!defined('SERVER_ID')) {
define('SERVER_ID', ConnectionTracker::getMainID());
@@ -52,7 +53,7 @@ if (isset($_SESSION['phash'])) {
|| $rUserInfo['admin_enabled'] == 0
|| $rUserInfo['enabled'] == 0
) {
- destroySession('player');
+ SessionManager::clearContext('player');
$code = $_SERVER['XC_CODE'] ?? '';
header('Location: ' . ($code ? '/' . $code . '/login' : 'login'));
exit();
diff --git a/src/infrastructure/bootstrap/reseller_functions.php b/src/infrastructure/bootstrap/reseller_functions.php
index a8d6998e..cd5958b6 100644
--- a/src/infrastructure/bootstrap/reseller_functions.php
+++ b/src/infrastructure/bootstrap/reseller_functions.php
@@ -17,7 +17,8 @@ if (!defined('MAIN_HOME')) {
define('MAIN_HOME', '/home/xc_vm/');
}
-require_once MAIN_HOME . 'includes/admin.php';
+require_once MAIN_HOME . 'bootstrap.php';
+XC_Bootstrap::boot(XC_Bootstrap::CONTEXT_ADMIN);
if ($rMobile) {
$rSettings['js_navigate'] = 0;
@@ -34,7 +35,7 @@ if (isset($_SESSION['reseller'])) {
setcookie('theme', $rUserInfo['theme'], time() + 604800);
$language::setLanguage($rUserInfo['lang']);
- $rPermissions = array_merge(getPermissions($rUserInfo['member_group_id']), getGroupPermissions($rUserInfo['id']));
+ $rPermissions = array_merge(AuthRepository::getPermissions($rUserInfo['member_group_id']), AuthRepository::getGroupPermissions($rUserInfo['id']));
$rPermissions['direct_reports'] = $rPermissions['direct_reports'] ?? [];
$rPermissions['all_reports'] = $rPermissions['all_reports'] ?? [];
$rPermissions['stream_ids'] = $rPermissions['stream_ids'] ?? [];
@@ -48,7 +49,7 @@ if (isset($_SESSION['reseller'])) {
if (!$rUserInfo || !$rPermissions || !$rPermissions['is_reseller'] || !$rIPMatch && $rSettings['ip_logout'] || $_SESSION['rverify'] != md5($rUserInfo['username'] . '||' . $rUserInfo['password'])) {
unset($rUserInfo, $rPermissions);
- destroySession('reseller');
+ SessionManager::clearContext('reseller');
header('Location: ./index');
exit();
@@ -62,5 +63,5 @@ if (isset(RequestManager::getAll()['status'])) {
$_STATUS = intval(RequestManager::getAll()['status']);
$rArgs = RequestManager::getAll();
unset($rArgs['status']);
- $customScript = setArgs($rArgs);
+ $customScript = AdminHelpers::setArgs($rArgs);
}
diff --git a/src/infrastructure/legacy/reseller_api_actions.php b/src/infrastructure/legacy/reseller_api_actions.php
index 4784d270..f4b40c56 100644
--- a/src/infrastructure/legacy/reseller_api_actions.php
+++ b/src/infrastructure/legacy/reseller_api_actions.php
@@ -92,7 +92,7 @@ if ($action == 'line') {
if (Authorization::check('line', $rUserID) && $rLine) {
if ($rSub == 'delete') {
- deleteLine($rUserID);
+ LineService::deleteLineById($rUserID);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'line', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'delete', RequestManager::getAll()['user_id'], 0, $rUserInfo['credits'], time(), json_encode($rLine));
echo json_encode(array('result' => true));
exit();
@@ -225,7 +225,7 @@ if ($action == 'reg_user') {
if ($rPermissions['delete_users']) {
$rOwnerCredits = intval($rUserInfo['credits']) + intval($rUser['credits']);
$db->query('UPDATE `users` SET `credits` = ? WHERE `id` = ?;', $rOwnerCredits, $rUserInfo['id']);
- deleteUser(RequestManager::getAll()['user_id'], false, false, $rUserInfo['id']);
+ UserService::deleteRegisteredUser(RequestManager::getAll()['user_id'], false, false, $rUserInfo['id']);
$db->query('INSERT INTO `users_credits_logs`(`target_id`, `admin_id`, `amount`, `date`, `reason`) VALUES(?, ?, ?, ?, ?);', $rUserInfo['id'], $rUserInfo['id'], intval($rUser['credits']), time(), 'Deleted user: ' . $rUser['username']);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'user', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'delete', RequestManager::getAll()['user_id'], intval($rUser['credits']), $rOwnerCredits, time(), json_encode($rUser));
echo json_encode(array('result' => true));
@@ -259,7 +259,7 @@ if ($action == 'reg_user') {
}
if ($action == 'ticket') {
- $rTicket = getTicket(RequestManager::getAll()['ticket_id']);
+ $rTicket = TicketRepository::getById(RequestManager::getAll()['ticket_id']);
if ($rTicket) {
if (Authorization::check('user', $rTicket['member_id'])) {
@@ -292,12 +292,12 @@ if ($action == 'ticket') {
if ($action == 'mag') {
if ($rPermissions['create_mag']) {
$rSub = RequestManager::getAll()['sub'];
- $rMagDetails = getMag(intval(RequestManager::getAll()['mag_id']));
+ $rMagDetails = MagService::getById(intval(RequestManager::getAll()['mag_id']));
if ($rMagDetails) {
if (Authorization::check('line', $rMagDetails['user_id'])) {
if ($rSub == 'delete') {
- deleteMAG(RequestManager::getAll()['mag_id']);
+ MagService::deleteDevice(RequestManager::getAll()['mag_id']);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'mag', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'delete', RequestManager::getAll()['mag_id'], 0, $rUserInfo['credits'], time(), json_encode($rMagDetails));
echo json_encode(array('result' => true));
exit();
@@ -318,7 +318,7 @@ if ($action == 'mag') {
}
if ($rSub == 'convert') {
- deleteMAG(RequestManager::getAll()['mag_id'], false, false, true);
+ MagService::deleteDevice(RequestManager::getAll()['mag_id'], false, false, true);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'line', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'convert', $rMagDetails['user']['id'], 0, $rUserInfo['credits'], time(), json_encode($rMagDetails['user']));
echo json_encode(array('result' => true, 'line_id' => $rMagDetails['user']['id']));
exit();
@@ -364,12 +364,12 @@ if ($action == 'mag') {
if ($action == 'enigma') {
if ($rPermissions['create_enigma']) {
$rSub = RequestManager::getAll()['sub'];
- $rE2Details = getEnigma(intval(RequestManager::getAll()['e2_id']));
+ $rE2Details = EnigmaService::getById(intval(RequestManager::getAll()['e2_id']));
if ($rE2Details) {
if (Authorization::check('line', $rE2Details['user_id'])) {
if ($rSub == 'delete') {
- deleteEnigma(RequestManager::getAll()['e2_id']);
+ EnigmaService::deleteDevice(RequestManager::getAll()['e2_id']);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'enigma', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'delete', RequestManager::getAll()['e2_id'], 0, $rUserInfo['credits'], time(), json_encode($rE2Details));
echo json_encode(array('result' => true));
exit();
@@ -390,7 +390,7 @@ if ($action == 'enigma') {
}
if ($rSub == 'convert') {
- deleteEnigma(RequestManager::getAll()['e2_id'], false, false, true);
+ EnigmaService::deleteDevice(RequestManager::getAll()['e2_id'], false, false, true);
$db->query("INSERT INTO `users_logs`(`owner`, `type`, `action`, `log_id`, `package_id`, `cost`, `credits_after`, `date`, `deleted_info`) VALUES(?, 'line', ?, ?, null, ?, ?, ?, ?);", $rUserInfo['id'], 'convert', $rE2Details['user']['id'], 0, $rUserInfo['credits'], time(), json_encode($rE2Details['user']));
echo json_encode(array('result' => true, 'line_id' => $rE2Details['user']['id']));
exit();
@@ -446,7 +446,7 @@ if ($action == 'get_package') {
}
if (isset(RequestManager::getAll()['orig_id']) && $rData['check_compatible']) {
- $rData['compatible'] = checkCompatible(RequestManager::getAll()['package_id'], RequestManager::getAll()['orig_id']);
+ $rData['compatible'] = PackageService::checkCompatible(RequestManager::getAll()['package_id'], RequestManager::getAll()['orig_id']);
} else {
$rData['compatible'] = true;
}
@@ -591,7 +591,7 @@ if ($action == 'userlist') {
if ($action == 'send_event') {
if ($rPermissions['create_mag']) {
$rData = json_decode(RequestManager::getAll()['data'], true);
- $rMag = getMag($rData['id']);
+ $rMag = MagService::getById($rData['id']);
if ($rMag) {
if (Authorization::check('line', $rMag['user_id'])) {
@@ -602,7 +602,7 @@ if ($action == 'send_event') {
$rData['reboot_portal'] = 0;
$rData['message'] = intval($rData['channel']);
} else if ($rData['type'] == 'reset_stb_lock') {
- resetSTB($rData['id']);
+ MagService::resetSTB($rData['id']);
echo json_encode(array('result' => true));
exit();
} else {
diff --git a/src/infrastructure/legacy/reseller_table_body.php b/src/infrastructure/legacy/reseller_table_body.php
index be3a33b7..70b3b1ee 100644
--- a/src/infrastructure/legacy/reseller_table_body.php
+++ b/src/infrastructure/legacy/reseller_table_body.php
@@ -1550,7 +1550,7 @@ if (isset($rUserInfo['reports'])) {
$rReturn['recordsFiltered'] = $rReturn['recordsTotal'];
if (0 >= $rReturn['recordsTotal']) {
} else {
- $rPackages = getPackages();
+ $rPackages = PackageService::getAll();
$rQuery = 'SELECT `users`.`username`, `users_logs`.`id`, `users_logs`.`owner`, `users_logs`.`type`, `users_logs`.`action`, `users_logs`.`log_id`, `users_logs`.`package_id`, `users_logs`.`cost`, `users_logs`.`credits_after`, `users_logs`.`date`, `users_logs`.`deleted_info` FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` ' . $rWhereString . ' ' . $rOrderBy . ' LIMIT ' . $rStart . ', ' . $rLimit . ';';
$db->query($rQuery, ...$rWhereV);
if (0 >= $db->num_rows()) {
@@ -1614,14 +1614,14 @@ if (isset($rUserInfo['reports'])) {
}
break;
case 'mag':
- $rLine = getMag($rRow['log_id']);
+ $rLine = MagService::getById($rRow['log_id']);
if (!$rLine) {
} else {
$rLineInfo = "" . $rLine['mac'] . '';
}
break;
case 'enigma':
- $rLine = getEnigma($rRow['log_id']);
+ $rLine = EnigmaService::getById($rRow['log_id']);
if (!$rLine) {
} else {
$rLineInfo = "" . $rLine['mac'] . '';
diff --git a/src/modules/plex/PlexController.php b/src/modules/plex/PlexController.php
index 8815eec8..235f5792 100644
--- a/src/modules/plex/PlexController.php
+++ b/src/modules/plex/PlexController.php
@@ -90,9 +90,9 @@ class PlexController {
*/
public function add() {
if (isset(RequestManager::getAll()['id'])) {
- $rFolder = getWatchFolder(RequestManager::getAll()['id']);
+ $rFolder = StreamRepository::getWatchFolder(RequestManager::getAll()['id']);
if (!$rFolder) {
- goHome();
+ AdminHelpers::goHome();
return;
}
}
@@ -156,7 +156,7 @@ class PlexController {
* Заменяет admin/api.php action=kill_plex
*/
public function apiKill() {
- killPlexSync();
+ ServerService::killPlexSync();
echo json_encode(['result' => true]);
exit();
}
@@ -171,13 +171,13 @@ class PlexController {
$rFolderID = RequestManager::getAll()['folder_id'] ?? 0;
if ($rSub === 'delete') {
- deleteWatchFolder($rFolderID);
+ StreamRepository::deleteWatchFolder($rFolderID);
echo json_encode(['result' => true]);
exit();
}
if ($rSub === 'force') {
- $rFolder = getWatchFolder($rFolderID);
+ $rFolder = StreamRepository::getWatchFolder($rFolderID);
if ($rFolder) {
PlexService::forcePlex($rFolder['server_id'], $rFolder['id']);
echo json_encode(['result' => true]);
diff --git a/src/modules/plex/PlexCron.php b/src/modules/plex/PlexCron.php
index c9a77125..0361f3f9 100644
--- a/src/modules/plex/PlexCron.php
+++ b/src/modules/plex/PlexCron.php
@@ -335,9 +335,9 @@ class PlexCron {
$cacheDataKey = array();
foreach ($rThreadData as $rData) {
if ($rData['type'] == 'movie') {
- $rCommand = '/usr/bin/timeout 20 ' . PHP_BIN . ' ' . INCLUDES_PATH . 'cli/plex_item.php "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
+ $rCommand = '/usr/bin/timeout 20 ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php plex_item "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
} else {
- $rCommand = '/usr/bin/timeout 300 ' . PHP_BIN . ' ' . INCLUDES_PATH . 'cli/plex_item.php "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
+ $rCommand = '/usr/bin/timeout 300 ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php plex_item "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
}
$cacheDataKey[] = $rCommand;
}
diff --git a/src/modules/plex/PlexService.php b/src/modules/plex/PlexService.php
index 55e54a46..e45e3256 100644
--- a/src/modules/plex/PlexService.php
+++ b/src/modules/plex/PlexService.php
@@ -38,16 +38,16 @@ class PlexService {
}
$db->query('UPDATE `settings` SET `scan_seconds` = ?, `max_genres` = ?, `thread_count_movie` = ?, `thread_count_show` = ?;', $rData['scan_seconds'], $rData['max_genres'], $rData['thread_count_movie'], $rData['thread_count_show']);
- clearSettingsCache();
+ SettingsManager::clearCache();
return array('status' => STATUS_SUCCESS);
}
public static function processPlexSync($rData) {
global $db;
if (isset($rData['edit'])) {
- $rArray = overwriteData(getWatchFolder($rData['edit']), $rData);
+ $rArray = AdminHelpers::overwriteData(StreamRepository::getWatchFolder($rData['edit']), $rData);
} else {
- $rArray = verifyPostTable('watch_folders', $rData);
+ $rArray = QueryHelper::verifyPostTable('watch_folders', $rData);
unset($rArray['id']);
}
@@ -92,7 +92,7 @@ class PlexService {
$rArray['bouquets'] = '[' . implode(',', array_map('intval', $overrideBouquets)) . ']';
$rArray['fb_bouquets'] = '[' . implode(',', array_map('intval', $fallbackBouquets)) . ']';
$rArray['target_container'] = ($rData['target_container'] == 'auto' ? null : $rData['target_container']);
- $rPrepare = prepareArray($rArray);
+ $rPrepare = QueryHelper::prepareArray($rArray);
$rQuery = 'REPLACE INTO `watch_folders`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
if ($db->query($rQuery, ...$rPrepare['data'])) {
@@ -103,6 +103,6 @@ class PlexService {
}
public static function forcePlex($rServerID, $rPlexID) {
- systemapirequest($rServerID, array('action' => 'plex_force', 'id' => $rPlexID));
+ ApiClient::systemRequest($rServerID, array('action' => 'plex_force', 'id' => $rPlexID));
}
}
diff --git a/src/modules/tmdb/TmdbCron.php b/src/modules/tmdb/TmdbCron.php
index d9b00642..f73a3b03 100644
--- a/src/modules/tmdb/TmdbCron.php
+++ b/src/modules/tmdb/TmdbCron.php
@@ -70,10 +70,11 @@ class TmdbCron {
foreach ($rResults as $rResultArr) {
$rPercentage = 0;
$rPercentageAlt = 0;
+ $rResultName = (string)($rResultArr->get('title') ?: $rResultArr->get('name'));
similar_text(
strtoupper($title),
- strtoupper(($rResultArr->get('title') ?: $rResultArr->get('name'))),
+ strtoupper($rResultName),
$rPercentage
);
@@ -81,7 +82,7 @@ class TmdbCron {
} else {
similar_text(
strtoupper($altTitle),
- strtoupper(($rResultArr->get('title') ?: $rResultArr->get('name'))),
+ strtoupper($rResultName),
$rPercentageAlt
);
}
@@ -90,15 +91,15 @@ class TmdbCron {
|| SettingsManager::getAll()['percentage_match'] <= $rPercentageAlt)) {
} else {
if ($year && !in_array(
- intval(substr(($rResultArr->get('release_date') ?: $rResultArr->get('first_air_date')), 0, 4)),
+ intval(substr((string)($rResultArr->get('release_date') ?: $rResultArr->get('first_air_date')), 0, 4)),
range(intval($year) - 1, intval($year) + 1)
)) {
} else {
- if ($altTitle && strtolower(($rResultArr->get('title') ?: $rResultArr->get('name'))) == strtolower($altTitle)) {
+ if ($altTitle && strtolower($rResultName) == strtolower($altTitle)) {
$rMatches = array(array('percentage' => 100, 'data' => $rResultArr));
break;
}
- if (strtolower(($rResultArr->get('title') ?: $rResultArr->get('name'))) == strtolower($title) && !$altTitle) {
+ if (strtolower($rResultName) == strtolower($title) && !$altTitle) {
$rMatches = array(array('percentage' => 100, 'data' => $rResultArr));
break;
}
@@ -161,7 +162,7 @@ class TmdbCron {
if ($rTMDBID == 0) {
$rFilename = pathinfo(json_decode($rStream['stream_source'], true)[0])['filename'];
foreach (array($rFilename, $rStream['stream_display_name']) as $rStreamTitle) {
- $rRelease = parserelease($rStreamTitle);
+ $rRelease = AdminHelpers::parserelease($rStreamTitle);
$rTitle = $rRelease['title'];
if (!isset($rRelease['excess'])) {
@@ -340,7 +341,7 @@ class TmdbCron {
/* --- Если TMDB ID неизвестен — ищем --- */
if ($rTMDBID == 0) {
$rFilename = $rStream['title'];
- $rRelease = parserelease($rFilename);
+ $rRelease = AdminHelpers::parserelease($rFilename);
$rTitle = $rRelease['title'];
if (!isset($rRelease['excess'])) {
@@ -378,7 +379,7 @@ class TmdbCron {
$rSeriesArray['plot'] = $rShowData['overview'];
$rSeriesArray['rating'] = $rShowData['vote_average'];
$rSeriesArray['release_date'] = $rShowData['first_air_date'];
- $rSeriesArray['youtube_trailer'] = getSeriesTrailer($rShowData['id']);
+ $rSeriesArray['youtube_trailer'] = TMDbService::getSeriesTrailer($rShowData['id']);
$rSeriesArray['cover'] = ($rShowData['poster_path']
? 'https://image.tmdb.org/t/p/w600_and_h900_bestv2' . $rShowData['poster_path']
: '');
@@ -439,7 +440,7 @@ class TmdbCron {
$rSeriesArray['episode_run_time'] = intval($rShowData['episode_run_time'][0]);
- $rPrepare = prepareArray($rSeriesArray);
+ $rPrepare = QueryHelper::prepareArray($rSeriesArray);
$rQuery = 'REPLACE INTO `streams_series`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
if ($db->query($rQuery, ...$rPrepare['data'])) {
@@ -502,7 +503,7 @@ class TmdbCron {
}
$rFilename = pathinfo(json_decode($rStream['stream_source'], true)[0])['filename'];
- $rRelease = parserelease($rFilename);
+ $rRelease = AdminHelpers::parserelease($rFilename);
$rReleaseSeason = $rRelease['season'];
if (is_array($rRelease['episode'])) {
@@ -601,8 +602,8 @@ class TmdbCron {
public static function run(): void {
global $db;
- require_once INCLUDES_PATH . 'libs/tmdb.php';
- require_once INCLUDES_PATH . 'libs/tmdb_release.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/Release.php';
$rUpdateSeries = array();
diff --git a/src/modules/tmdb/TmdbCronJob.php b/src/modules/tmdb/TmdbCronJob.php
index 65695d01..7a9f42c4 100644
--- a/src/modules/tmdb/TmdbCronJob.php
+++ b/src/modules/tmdb/TmdbCronJob.php
@@ -28,9 +28,8 @@ class TmdbCronJob implements CommandInterface {
return 1;
}
- require INCLUDES_PATH . 'admin.php';
- require_once INCLUDES_PATH . 'libs/tmdb.php';
- require_once INCLUDES_PATH . 'libs/tmdb_release.php';
+ require MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/Release.php';
require_once __DIR__ . '/TmdbCron.php';
$this->initCron('XC_VM[TMDB]');
diff --git a/src/modules/tmdb/TmdbPopularCron.php b/src/modules/tmdb/TmdbPopularCron.php
index a0ee4692..9e837034 100644
--- a/src/modules/tmdb/TmdbPopularCron.php
+++ b/src/modules/tmdb/TmdbPopularCron.php
@@ -173,7 +173,7 @@ class TmdbPopularCron {
public static function run(): void {
global $db;
- require_once MAIN_HOME . 'includes/libs/tmdb.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
if (strlen(SettingsManager::getAll()['tmdb_api_key'] ?? '') > 0) {
$lang = SettingsManager::getAll()['tmdb_language'] ?? '';
diff --git a/src/modules/tmdb/TmdbPopularCronJob.php b/src/modules/tmdb/TmdbPopularCronJob.php
index aedbe69e..6b87d32f 100644
--- a/src/modules/tmdb/TmdbPopularCronJob.php
+++ b/src/modules/tmdb/TmdbPopularCronJob.php
@@ -30,7 +30,7 @@ class TmdbPopularCronJob implements CommandInterface {
$this->initCron('XC_VM[Popular]');
- require_once INCLUDES_PATH . 'libs/tmdb.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
require_once __DIR__ . '/TmdbPopularCron.php';
TmdbPopularCron::run();
diff --git a/src/modules/tmdb/TmdbService.php b/src/modules/tmdb/TmdbService.php
index 58fd26cf..ef884ed1 100644
--- a/src/modules/tmdb/TmdbService.php
+++ b/src/modules/tmdb/TmdbService.php
@@ -76,7 +76,7 @@ class TmdbService {
}
// Текстовый поиск
- $rRelease = parserelease($term);
+ $rRelease = AdminHelpers::parserelease($term);
$searchTerm = $rRelease['title'];
$rJSON = [];
@@ -123,7 +123,7 @@ class TmdbService {
$rSeries = $rTMDB->getTVShow($id);
$rResult = json_decode($rSeries->getJSON(), true);
$settingsLang = SettingsManager::getAll()['tmdb_language'] ?? '';
- $rResult['trailer'] = getSeriesTrailer($id, ($language ?: $settingsLang));
+ $rResult['trailer'] = TMDbService::getSeriesTrailer($id, ($language ?: $settingsLang));
}
if (!$rResult) {
@@ -168,7 +168,7 @@ class TmdbService {
private static function requireLibrary(): void {
static $loaded = false;
if (!$loaded) {
- require_once INCLUDES_PATH . 'libs/tmdb.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
$loaded = true;
}
}
diff --git a/src/modules/tmdb/lib.php b/src/modules/tmdb/lib.php
index 024aa9ee..8db16e50 100644
--- a/src/modules/tmdb/lib.php
+++ b/src/modules/tmdb/lib.php
@@ -20,4 +20,4 @@
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
*/
-require_once INCLUDES_PATH . 'libs/tmdb.php';
+require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
diff --git a/src/modules/watch/RecordingService.php b/src/modules/watch/RecordingService.php
index f73117b9..b7f84522 100644
--- a/src/modules/watch/RecordingService.php
+++ b/src/modules/watch/RecordingService.php
@@ -20,10 +20,10 @@ class RecordingService {
return array('status' => STATUS_NO_SOURCE);
}
- $rArray = verifyPostTable('recordings', $rData);
+ $rArray = QueryHelper::verifyPostTable('recordings', $rData);
$rArray['bouquets'] = '[' . implode(',', array_map('intval', $rData['bouquets'])) . ']';
$rArray['category_id'] = '[' . implode(',', array_map('intval', $rData['category_id'])) . ']';
- $rPrepare = prepareArray($rArray);
+ $rPrepare = QueryHelper::prepareArray($rArray);
$rQuery = 'REPLACE INTO `recordings`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
if ($db->query($rQuery, ...$rPrepare['data'])) {
diff --git a/src/modules/watch/WatchController.php b/src/modules/watch/WatchController.php
index 394f68d0..1c9e5397 100644
--- a/src/modules/watch/WatchController.php
+++ b/src/modules/watch/WatchController.php
@@ -95,9 +95,9 @@ class WatchController {
global $db;
if (isset(RequestManager::getAll()['id'])) {
- $rFolder = getWatchFolder(RequestManager::getAll()['id']);
+ $rFolder = StreamRepository::getWatchFolder(RequestManager::getAll()['id']);
if (!$rFolder) {
- goHome();
+ AdminHelpers::goHome();
return;
}
}
@@ -160,7 +160,7 @@ class WatchController {
RequestManager::getAll()['programme']
);
if (!$rStream || $rStream['type'] != 1 || !$rProgramme) {
- goHome();
+ AdminHelpers::goHome();
return;
}
} elseif (isset(RequestManager::getAll()['archive'])) {
@@ -174,7 +174,7 @@ class WatchController {
'archive' => true,
];
if (!$rStream || $rStream['type'] != 1 || !$rProgramme) {
- goHome();
+ AdminHelpers::goHome();
return;
}
} elseif (isset(RequestManager::getAll()['stream_id'])) {
@@ -261,13 +261,13 @@ class WatchController {
$rFolderID = RequestManager::getAll()['folder_id'] ?? 0;
if ($rSub === 'delete') {
- deleteWatchFolder($rFolderID);
+ StreamRepository::deleteWatchFolder($rFolderID);
echo json_encode(['result' => true]);
exit();
}
if ($rSub === 'force') {
- $rFolder = getWatchFolder($rFolderID);
+ $rFolder = StreamRepository::getWatchFolder($rFolderID);
if ($rFolder) {
WatchService::forceWatch($rFolder['server_id'], $rFolder['id']);
echo json_encode(['result' => true]);
diff --git a/src/modules/watch/WatchCron.php b/src/modules/watch/WatchCron.php
index 3b5638b9..e19ee6cf 100644
--- a/src/modules/watch/WatchCron.php
+++ b/src/modules/watch/WatchCron.php
@@ -230,7 +230,7 @@ class WatchCron {
}
$cacheDataKey = array();
foreach ($rThreadData as $rData) {
- $rCommand = '/usr/bin/timeout 60 ' . PHP_BIN . ' ' . INCLUDES_PATH . 'cli/watch_item.php "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
+ $rCommand = '/usr/bin/timeout 60 ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php watch_item "' . base64_encode(json_encode($rData, JSON_UNESCAPED_UNICODE)) . '"';
$cacheDataKey[] = $rCommand;
}
$db->close_mysql();
diff --git a/src/modules/watch/WatchItem.php b/src/modules/watch/WatchItem.php
index 3dafa579..c2f7dc0d 100644
--- a/src/modules/watch/WatchItem.php
+++ b/src/modules/watch/WatchItem.php
@@ -131,7 +131,7 @@ class WatchItem {
if ($rType == 'guessit') {
$rCommand = MAIN_HOME . 'bin/guess ' . escapeshellarg($rRelease . '.mkv');
} else {
- $rCommand = '/usr/bin/python3 ' . MAIN_HOME . 'includes/python/release.py ' . escapeshellarg(str_replace('-', '_', $rRelease));
+ $rCommand = '/usr/bin/python3 ' . MAIN_HOME . 'bin/python/release.py ' . escapeshellarg(str_replace('-', '_', $rRelease));
}
return json_decode(shell_exec($rCommand), true);
}
diff --git a/src/modules/watch/WatchItemCommand.php b/src/modules/watch/WatchItemCommand.php
index 466b5827..2fed0a94 100644
--- a/src/modules/watch/WatchItemCommand.php
+++ b/src/modules/watch/WatchItemCommand.php
@@ -49,8 +49,8 @@ class WatchItemCommand implements CommandInterface {
@unlink(WATCH_TMP_PATH . @getmypid() . '.wpid');
});
- require_once INCLUDES_PATH . 'libs/tmdb.php';
- require INCLUDES_PATH . 'libs/tmdb_release.php';
+ require_once MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
+ require MAIN_HOME . 'modules/tmdb/lib/Release.php';
$rThreadData = json_decode(base64_decode($rArgs[0]), true);
if (!$rThreadData) {
diff --git a/src/modules/watch/WatchService.php b/src/modules/watch/WatchService.php
index ccc7ddb2..e656203f 100644
--- a/src/modules/watch/WatchService.php
+++ b/src/modules/watch/WatchService.php
@@ -33,7 +33,7 @@ class WatchService {
$fallbackParser = isset($rData['fallback_parser']);
$db->query('UPDATE `settings` SET `percentage_match` = ?, `scan_seconds` = ?, `thread_count` = ?, `max_genres` = ?, `max_items` = ?, `alternative_titles` = ?, `fallback_parser` = ?;', $rData['percentage_match'], $rData['scan_seconds'], $rData['thread_count'], $rData['max_genres'], $rData['max_items'], $altTitles, $fallbackParser);
- clearSettingsCache();
+ SettingsManager::clearCache();
return array('status' => STATUS_SUCCESS);
}
@@ -41,9 +41,9 @@ class WatchService {
public static function processWatchFolder($rData) {
global $db;
if (isset($rData['edit'])) {
- $rArray = overwriteData(getWatchFolder($rData['edit']), $rData);
+ $rArray = AdminHelpers::overwriteData(StreamRepository::getWatchFolder($rData['edit']), $rData);
} else {
- $rArray = verifyPostTable('watch_folders', $rData);
+ $rArray = QueryHelper::verifyPostTable('watch_folders', $rData);
unset($rArray['id']);
}
@@ -78,7 +78,7 @@ class WatchService {
$rArray[$rKey] = isset($rData[$rKey]) ? 1 : 0;
}
- $rPrepare = prepareArray($rArray);
+ $rPrepare = QueryHelper::prepareArray($rArray);
$rQuery = 'REPLACE INTO `watch_folders`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');';
if ($db->query($rQuery, ...$rPrepare['data'])) {
@@ -117,7 +117,7 @@ class WatchService {
}
public static function forceWatch($rServerID, $rWatchID) {
- return systemapirequest($rServerID, array('action' => 'watch_force', 'id' => $rWatchID));
+ return ApiClient::systemRequest($rServerID, array('action' => 'watch_force', 'id' => $rWatchID));
}
public static function enableWatch() {
@@ -135,7 +135,7 @@ class WatchService {
$db->query("SELECT DISTINCT(`server_id`) AS `server_id` FROM `watch_folders` WHERE `active` = 11 AND `type` <> 'plex';");
foreach ($db->get_rows() as $rRow) {
if (ServerRepository::getAll()[$rRow['server_id']]['server_online']) {
- systemapirequest($rRow['server_id'], array('action' => 'kill_watch'));
+ ApiClient::systemRequest($rRow['server_id'], array('action' => 'kill_watch'));
}
}
return true;
@@ -157,7 +157,7 @@ class WatchService {
if ($db->num_rows() > 0) {
$rRecording = $db->get_row();
if ($rRecording['created_id']) {
- deleteStream($rRecording['created_id'], $rRecording['source_id'], true, true);
+ StreamRepository::deleteStream($rRecording['created_id'], $rRecording['source_id'], true, true);
}
shell_exec("kill -9 `ps -ef | grep 'Record[" . intval($rID) . "]' | grep -v grep | awk '{print $2}'`");
$db->query('DELETE FROM `recordings` WHERE `id` = ?;', $rID);
diff --git a/src/public/Controllers/Admin/AdminLogoutController.php b/src/public/Controllers/Admin/AdminLogoutController.php
index 60075eef..8b194456 100644
--- a/src/public/Controllers/Admin/AdminLogoutController.php
+++ b/src/public/Controllers/Admin/AdminLogoutController.php
@@ -14,8 +14,8 @@ class AdminLogoutController extends BaseAdminController
{
public function index()
{
- if (function_exists('destroySession')) {
- destroySession();
+ if (class_exists('SessionManager')) {
+ SessionManager::clearContext('admin');
}
$this->redirect('./login');
}
diff --git a/src/public/Controllers/Admin/ArchiveController.php b/src/public/Controllers/Admin/ArchiveController.php
index 32f88f12..f2fe0f90 100644
--- a/src/public/Controllers/Admin/ArchiveController.php
+++ b/src/public/Controllers/Admin/ArchiveController.php
@@ -27,7 +27,7 @@ class ArchiveController extends BaseAdminController
return;
}
- $rArchive = getArchive($rStream['id']);
+ $rArchive = StreamService::getArchive($rStream['id']);
} else {
$rRecordings = WatchService::getRecordings();
}
diff --git a/src/public/Controllers/Admin/BaseAdminController.php b/src/public/Controllers/Admin/BaseAdminController.php
index f8b71142..203d2005 100644
--- a/src/public/Controllers/Admin/BaseAdminController.php
+++ b/src/public/Controllers/Admin/BaseAdminController.php
@@ -43,32 +43,28 @@ class BaseAdminController
}
/**
- * Проверка общих прав доступа (checkPermissions).
- * При отказе — goHome() + exit.
+ * Проверка общих прав доступа.
+ * При отказе — redirect на главную + exit.
*/
protected function requirePermission()
{
- if (function_exists('checkPermissions') && !checkPermissions()) {
- if (function_exists('goHome')) {
- goHome();
- }
+ if (!PageAuthorization::checkPermissions()) {
+ AdminHelpers::goHome();
exit;
}
}
/**
* Проверка расширенных прав (hasPermissions).
- * При отказе — goHome() + exit.
+ * При отказе — redirect на главную + exit.
*
* @param string $type Тип прав ('adv' и т.д.)
* @param string $key Ключ прав ('edit_user' и т.д.)
*/
protected function requireAdvPermission($type, $key)
{
- if (class_exists('Authorization') && !Authorization::check($type, $key)) {
- if (function_exists('goHome')) {
- goHome();
- }
+ if (!Authorization::check($type, $key)) {
+ AdminHelpers::goHome();
exit;
}
}
diff --git a/src/public/Controllers/Admin/BouquetController.php b/src/public/Controllers/Admin/BouquetController.php
index fe8c93cb..063efae9 100644
--- a/src/public/Controllers/Admin/BouquetController.php
+++ b/src/public/Controllers/Admin/BouquetController.php
@@ -37,9 +37,9 @@ class BouquetController extends BaseAdminController
$duplicateId = $this->input('duplicate');
if ($editId !== null) {
- $rBouquetArr = function_exists('getBouquet') ? getBouquet($editId) : null;
+ $rBouquetArr = BouquetService::getById($editId);
} elseif ($duplicateId !== null) {
- $rBouquetArr = function_exists('getBouquet') ? getBouquet($duplicateId) : null;
+ $rBouquetArr = BouquetService::getById($duplicateId);
if ($rBouquetArr) {
$rBouquetArr['bouquet_name'] .= ' - Copy';
unset($rBouquetArr['id']);
@@ -54,9 +54,7 @@ class BouquetController extends BaseAdminController
$rBouquetSeries = json_decode($rBouquetArr['bouquet_series'], true) ?: [];
// Имена потоков/фильмов/радио
- $rRequiredIDs = function_exists('confirmIDs')
- ? confirmIDs(array_merge($rBouquetChannels, $rBouquetMovies, $rBouquetRadios))
- : array_map('intval', array_merge($rBouquetChannels, $rBouquetMovies, $rBouquetRadios));
+ $rRequiredIDs = AdminHelpers::confirmIDs(array_merge($rBouquetChannels, $rBouquetMovies, $rBouquetRadios));
if (count($rRequiredIDs) > 0) {
global $db;
diff --git a/src/public/Controllers/Admin/BouquetSortController.php b/src/public/Controllers/Admin/BouquetSortController.php
index 08c83ab8..ab92d2dd 100644
--- a/src/public/Controllers/Admin/BouquetSortController.php
+++ b/src/public/Controllers/Admin/BouquetSortController.php
@@ -23,12 +23,10 @@ class BouquetSortController extends BaseAdminController
$this->requirePermission();
$bouquetId = $this->input('id');
- $rBouquet = ($bouquetId && function_exists('getBouquet')) ? getBouquet($bouquetId) : null;
+ $rBouquet = $bouquetId ? BouquetService::getById($bouquetId) : null;
if (!$rBouquet) {
- if (function_exists('goHome')) {
- goHome();
- }
+ AdminHelpers::goHome();
exit;
}
diff --git a/src/public/Controllers/Admin/CodeController.php b/src/public/Controllers/Admin/CodeController.php
index f6811bfa..3c4c364d 100644
--- a/src/public/Controllers/Admin/CodeController.php
+++ b/src/public/Controllers/Admin/CodeController.php
@@ -23,7 +23,7 @@ class CodeController extends BaseAdminController
$this->setTitle('Access Codes');
- $codes = function_exists('getcodes') ? getcodes() : [];
+ $codes = AuthRepository::getAllCodes();
$this->render('codes', [
'codes' => $codes,
diff --git a/src/public/Controllers/Admin/CodeEditController.php b/src/public/Controllers/Admin/CodeEditController.php
index c257bcd8..85259385 100644
--- a/src/public/Controllers/Admin/CodeEditController.php
+++ b/src/public/Controllers/Admin/CodeEditController.php
@@ -20,7 +20,7 @@ class CodeEditController extends BaseAdminController
$rCode = null;
$id = $this->input('id');
if ($id !== null) {
- $rCode = function_exists('getCode') ? getCode($id) : null;
+ $rCode = AuthRepository::getCodeById($id);
if (!$rCode) {
exit();
}
diff --git a/src/public/Controllers/Admin/CreatedChannelController.php b/src/public/Controllers/Admin/CreatedChannelController.php
index 0afb6740..5ca409d3 100644
--- a/src/public/Controllers/Admin/CreatedChannelController.php
+++ b/src/public/Controllers/Admin/CreatedChannelController.php
@@ -26,7 +26,7 @@ class CreatedChannelController extends BaseAdminController
$rChannel = StreamRepository::getById(RequestManager::getAll()['id']);
if (!$rChannel || $rChannel['type'] != 3) {
- goHome();
+ AdminHelpers::goHome();
}
}
diff --git a/src/public/Controllers/Admin/DashboardController.php b/src/public/Controllers/Admin/DashboardController.php
index c68cfe9c..8db1d0a0 100644
--- a/src/public/Controllers/Admin/DashboardController.php
+++ b/src/public/Controllers/Admin/DashboardController.php
@@ -3,7 +3,7 @@
* DashboardController — Dashboard page.
*
* Complex data-prep: theme colours, connection map queries, server stats.
- * Dashboard has NO checkPermissions() — it uses server_id validation instead.
+ * Dashboard has NO PageAuthorization::checkPermissions() — it uses server_id validation instead.
*
* @package XC_VM_Public_Controllers_Admin
* @author Divarion_D
diff --git a/src/public/Controllers/Admin/EnigmaController.php b/src/public/Controllers/Admin/EnigmaController.php
index 434e8fe2..d0970d14 100644
--- a/src/public/Controllers/Admin/EnigmaController.php
+++ b/src/public/Controllers/Admin/EnigmaController.php
@@ -15,7 +15,7 @@ class EnigmaController extends BaseAdminController {
$rDevice = null;
if (isset(RequestManager::getAll()['id'])) {
- $rDevice = getEnigma(RequestManager::getAll()['id']);
+ $rDevice = EnigmaService::getById(RequestManager::getAll()['id']);
if (!$rDevice['user_id']) {
exit();
}
diff --git a/src/public/Controllers/Admin/EpgListController.php b/src/public/Controllers/Admin/EpgListController.php
index 7a583e5d..08576037 100644
--- a/src/public/Controllers/Admin/EpgListController.php
+++ b/src/public/Controllers/Admin/EpgListController.php
@@ -23,7 +23,7 @@ class EpgListController extends BaseAdminController
$this->requirePermission();
$this->setTitle('EPG Files');
- $epgs = function_exists('getEPGs') ? getEPGs() : [];
+ $epgs = EpgService::getAll();
$this->render('epgs', [
'epgs' => $epgs,
diff --git a/src/public/Controllers/Admin/EpisodeController.php b/src/public/Controllers/Admin/EpisodeController.php
index 6ded822e..a559fc8d 100644
--- a/src/public/Controllers/Admin/EpisodeController.php
+++ b/src/public/Controllers/Admin/EpisodeController.php
@@ -25,7 +25,7 @@ class EpisodeController extends BaseAdminController
}
}
- if (!($rSeriesArr = getSerie(RequestManager::getAll()['sid'] ?? null))) {
+ if (!($rSeriesArr = SeriesService::getById(RequestManager::getAll()['sid'] ?? null))) {
$this->redirect('series');
return;
}
diff --git a/src/public/Controllers/Admin/EpisodeMassController.php b/src/public/Controllers/Admin/EpisodeMassController.php
index 9732eaed..637de0fe 100644
--- a/src/public/Controllers/Admin/EpisodeMassController.php
+++ b/src/public/Controllers/Admin/EpisodeMassController.php
@@ -17,7 +17,7 @@ class EpisodeMassController extends BaseAdminController
global $rServers;
- $rSeries = getSeries();
+ $rSeries = SeriesService::getAll();
$rServerTree = [
['id' => 'source', 'parent' => '#', 'text' => "Active", 'icon' => 'mdi mdi-play', 'state' => ['opened' => true]],
['id' => 'offline', 'parent' => '#', 'text' => "Offline", 'icon' => 'mdi mdi-stop', 'state' => ['opened' => true]],
diff --git a/src/public/Controllers/Admin/GroupEditController.php b/src/public/Controllers/Admin/GroupEditController.php
index 9ca6d541..e14ca867 100644
--- a/src/public/Controllers/Admin/GroupEditController.php
+++ b/src/public/Controllers/Admin/GroupEditController.php
@@ -28,9 +28,7 @@ class GroupEditController extends BaseAdminController
if ($id !== null) {
$rGroup = GroupService::getById($id);
if (!$rGroup) {
- if (function_exists('goHome')) {
- goHome();
- }
+ AdminHelpers::goHome();
return;
}
}
diff --git a/src/public/Controllers/Admin/IpController.php b/src/public/Controllers/Admin/IpController.php
index 7a618e88..3548615a 100644
--- a/src/public/Controllers/Admin/IpController.php
+++ b/src/public/Controllers/Admin/IpController.php
@@ -24,9 +24,7 @@ class IpController extends BaseAdminController
// Обработка flush перед рендером
if ($this->input('flush') !== null) {
- if (function_exists('flushIPs')) {
- flushIPs();
- }
+ BlocklistService::flushIPs();
$this->redirect('./ips?status=' . STATUS_FLUSH);
}
diff --git a/src/public/Controllers/Admin/IspController.php b/src/public/Controllers/Admin/IspController.php
index 5ddbff02..a41db2fe 100644
--- a/src/public/Controllers/Admin/IspController.php
+++ b/src/public/Controllers/Admin/IspController.php
@@ -23,7 +23,7 @@ class IspController extends BaseAdminController
$this->setTitle("Blocked ISP's");
- $isps = function_exists('getISPs') ? getISPs() : [];
+ $isps = BlocklistService::getAllISPs();
$this->render('isps', [
'isps' => $isps,
diff --git a/src/public/Controllers/Admin/IspEditController.php b/src/public/Controllers/Admin/IspEditController.php
index 6827ff39..6ed2c436 100644
--- a/src/public/Controllers/Admin/IspEditController.php
+++ b/src/public/Controllers/Admin/IspEditController.php
@@ -20,7 +20,7 @@ class IspEditController extends BaseAdminController
$rISPArr = null;
$id = $this->input('id');
if ($id !== null) {
- $rISPArr = function_exists('getISP') ? getISP($id) : null;
+ $rISPArr = BlocklistService::getISPById($id);
}
$this->setTitle('Blocked ISP');
diff --git a/src/public/Controllers/Admin/LineController.php b/src/public/Controllers/Admin/LineController.php
index aca8ae0c..d6d0fbcc 100644
--- a/src/public/Controllers/Admin/LineController.php
+++ b/src/public/Controllers/Admin/LineController.php
@@ -21,7 +21,7 @@ class LineController extends BaseAdminController
$rLine = UserRepository::getLineById(RequestManager::getAll()['id']);
if (!$rLine || !Authorization::check('adv', 'edit_user')) {
- goHome();
+ AdminHelpers::goHome();
}
if ($rLine['is_mag']) {
@@ -30,7 +30,7 @@ class LineController extends BaseAdminController
header('Location: mag?id=' . intval($db->get_row()['mag_id']));
exit;
} else {
- goHome();
+ AdminHelpers::goHome();
}
}
@@ -40,12 +40,12 @@ class LineController extends BaseAdminController
header('Location: enigma?id=' . intval($db->get_row()['device_id']));
exit;
} else {
- goHome();
+ AdminHelpers::goHome();
}
}
} else {
if (!Authorization::check('adv', 'add_user')) {
- goHome();
+ AdminHelpers::goHome();
}
$rLine = null;
}
diff --git a/src/public/Controllers/Admin/MagController.php b/src/public/Controllers/Admin/MagController.php
index 82dd2bf4..d16d6304 100644
--- a/src/public/Controllers/Admin/MagController.php
+++ b/src/public/Controllers/Admin/MagController.php
@@ -15,7 +15,7 @@ class MagController extends BaseAdminController {
$rDevice = null;
if (isset(RequestManager::getAll()['id'])) {
- $rDevice = getMag(RequestManager::getAll()['id']);
+ $rDevice = MagService::getById(RequestManager::getAll()['id']);
if (!$rDevice['user_id']) {
exit();
}
diff --git a/src/public/Controllers/Admin/PackageController.php b/src/public/Controllers/Admin/PackageController.php
index 99d03040..e00eaed8 100644
--- a/src/public/Controllers/Admin/PackageController.php
+++ b/src/public/Controllers/Admin/PackageController.php
@@ -23,7 +23,7 @@ class PackageController extends BaseAdminController
$this->setTitle('Packages');
- $allPackages = function_exists('getPackages') ? getPackages() : [];
+ $allPackages = PackageService::getAll();
// Фильтруем addon-пакеты (показываем только обычные)
$packages = array_filter($allPackages, function ($p) {
return empty($p['is_addon']);
diff --git a/src/public/Controllers/Admin/PackageEditController.php b/src/public/Controllers/Admin/PackageEditController.php
index 556e6cf3..87e98a59 100644
--- a/src/public/Controllers/Admin/PackageEditController.php
+++ b/src/public/Controllers/Admin/PackageEditController.php
@@ -20,11 +20,9 @@ class PackageEditController extends BaseAdminController
$rPackage = null;
$id = $this->input('id');
if ($id !== null) {
- $rPackage = function_exists('getPackage') ? getPackage($id) : null;
+ $rPackage = PackageService::getById($id);
if (!$rPackage) {
- if (function_exists('goHome')) {
- goHome();
- }
+ AdminHelpers::goHome();
return;
}
}
diff --git a/src/public/Controllers/Admin/PlexAddController.php b/src/public/Controllers/Admin/PlexAddController.php
index de234898..e1b91d7c 100644
--- a/src/public/Controllers/Admin/PlexAddController.php
+++ b/src/public/Controllers/Admin/PlexAddController.php
@@ -18,7 +18,7 @@ class PlexAddController extends BaseAdminController
$rFolder = null;
$id = $this->input('id');
if (isset($id)) {
- $rFolder = getWatchFolder($id);
+ $rFolder = StreamRepository::getWatchFolder($id);
if (!$rFolder) {
$this->redirect('plex');
return;
diff --git a/src/public/Controllers/Admin/ProcessMonitorController.php b/src/public/Controllers/Admin/ProcessMonitorController.php
index be19c0cb..b02aa046 100644
--- a/src/public/Controllers/Admin/ProcessMonitorController.php
+++ b/src/public/Controllers/Admin/ProcessMonitorController.php
@@ -35,7 +35,7 @@ class ProcessMonitorController extends BaseAdminController
$rStreams = StreamRepository::getPIDs(RequestManager::getAll()['server']) ?: array();
$rFS = ServerRepository::getFreeSpace(RequestManager::getAll()['server']) ?: array();
- $rProcesses = getPIDs(RequestManager::getAll()['server']) ?: array();
+ $rProcesses = DiagnosticsService::getPIDs(RequestManager::getAll()['server']) ?: array();
$rStatus = array('D' => 'Uninterruptible Sleep', 'I' => 'Idle', 'R' => 'Running', 'S' => 'Interruptible Sleep', 'T' => 'Stopped', 'W' => 'Paging', 'X' => 'Dead', 'Z' => 'Zombie');
$this->setTitle('Process Monitor');
diff --git a/src/public/Controllers/Admin/ProfileEditController.php b/src/public/Controllers/Admin/ProfileEditController.php
index 6f604d49..e37cc51c 100644
--- a/src/public/Controllers/Admin/ProfileEditController.php
+++ b/src/public/Controllers/Admin/ProfileEditController.php
@@ -24,11 +24,9 @@ class ProfileEditController extends BaseAdminController
$id = $this->input('id');
if ($id !== null) {
- $rProfileArr = function_exists('getTranscodeProfile') ? getTranscodeProfile($id) : null;
+ $rProfileArr = StreamConfigRepository::getTranscodeProfile($id);
if (!$rProfileArr) {
- if (function_exists('goHome')) {
- goHome();
- }
+ AdminHelpers::goHome();
return;
}
}
diff --git a/src/public/Controllers/Admin/ProviderController.php b/src/public/Controllers/Admin/ProviderController.php
index 36dfb242..391a3d74 100644
--- a/src/public/Controllers/Admin/ProviderController.php
+++ b/src/public/Controllers/Admin/ProviderController.php
@@ -18,7 +18,7 @@ class ProviderController extends BaseAdminController
$this->setTitle('Stream Providers');
$this->render('providers', [
- 'providers' => getStreamProviders(),
+ 'providers' => ProviderService::getAll(),
]);
}
}
diff --git a/src/public/Controllers/Admin/ProviderEditController.php b/src/public/Controllers/Admin/ProviderEditController.php
index 4deb3aa4..e5ab71e0 100644
--- a/src/public/Controllers/Admin/ProviderEditController.php
+++ b/src/public/Controllers/Admin/ProviderEditController.php
@@ -20,7 +20,7 @@ class ProviderEditController extends BaseAdminController
$rProvider = null;
$id = $this->input('id');
if ($id !== null) {
- $rProvider = function_exists('getStreamProvider') ? getStreamProvider($id) : null;
+ $rProvider = ProviderService::getById($id);
if (!$rProvider) {
exit();
}
diff --git a/src/public/Controllers/Admin/RadioController.php b/src/public/Controllers/Admin/RadioController.php
index 14269fc5..05eda481 100644
--- a/src/public/Controllers/Admin/RadioController.php
+++ b/src/public/Controllers/Admin/RadioController.php
@@ -20,7 +20,7 @@ class RadioController extends BaseAdminController
if (isset(RequestManager::getAll()['id'])) {
$rStation = StreamRepository::getById(RequestManager::getAll()['id']);
if (!$rStation || $rStation['type'] != 4) {
- goHome();
+ AdminHelpers::goHome();
}
}
diff --git a/src/public/Controllers/Admin/RtmpIpEditController.php b/src/public/Controllers/Admin/RtmpIpEditController.php
index ebec5d9b..6769bb7f 100644
--- a/src/public/Controllers/Admin/RtmpIpEditController.php
+++ b/src/public/Controllers/Admin/RtmpIpEditController.php
@@ -20,11 +20,9 @@ class RtmpIpEditController extends BaseAdminController
$rIPArr = null;
$id = $this->input('id');
if ($id !== null) {
- $rIPArr = function_exists('getRTMPIP') ? getRTMPIP($id) : null;
+ $rIPArr = BlocklistService::getRTMPIPById($id);
if (!$rIPArr) {
- if (function_exists('goHome')) {
- goHome();
- }
+ AdminHelpers::goHome();
return;
}
}
diff --git a/src/public/Controllers/Admin/SerieController.php b/src/public/Controllers/Admin/SerieController.php
index 96f9f12c..15bdd007 100644
--- a/src/public/Controllers/Admin/SerieController.php
+++ b/src/public/Controllers/Admin/SerieController.php
@@ -18,7 +18,7 @@ class SerieController extends BaseAdminController
global $rServers;
$rSeriesArr = null;
- if (isset(RequestManager::getAll()['id']) && !($rSeriesArr = getSerie(RequestManager::getAll()['id']))) {
+ if (isset(RequestManager::getAll()['id']) && !($rSeriesArr = SeriesService::getById(RequestManager::getAll()['id']))) {
$this->redirect('series');
return;
}
diff --git a/src/public/Controllers/Admin/SettingsController.php b/src/public/Controllers/Admin/SettingsController.php
index 5c0db45d..b52ecb1f 100644
--- a/src/public/Controllers/Admin/SettingsController.php
+++ b/src/public/Controllers/Admin/SettingsController.php
@@ -20,7 +20,7 @@ class SettingsController extends BaseAdminController
{
$this->requirePermission();
- $rSettings = getSettings();
+ $rSettings = SettingsManager::getAll();
$rStreamArguments = StreamConfigRepository::getStreamArguments();
$versionData = json_decode(@file_get_contents(BIN_PATH . 'maxmind/version.json'), true) ?: [];
diff --git a/src/public/Controllers/Admin/StreamCategoryController.php b/src/public/Controllers/Admin/StreamCategoryController.php
index cc34d709..c3ec6fb6 100644
--- a/src/public/Controllers/Admin/StreamCategoryController.php
+++ b/src/public/Controllers/Admin/StreamCategoryController.php
@@ -16,7 +16,7 @@ class StreamCategoryController extends BaseAdminController
$this->requirePermission();
if (isset(RequestManager::getAll()['id'])) {
- $rCategoryArr = getCategory(RequestManager::getAll()['id']);
+ $rCategoryArr = CategoryService::getById(RequestManager::getAll()['id']);
if (!$rCategoryArr || !Authorization::check('adv', 'edit_cat')) {
exit();
}
diff --git a/src/public/Controllers/Admin/StreamController.php b/src/public/Controllers/Admin/StreamController.php
index 702f5ecc..7292618a 100644
--- a/src/public/Controllers/Admin/StreamController.php
+++ b/src/public/Controllers/Admin/StreamController.php
@@ -31,7 +31,7 @@ class StreamController extends BaseAdminController
}
}
- $rEPGSources = getEPGSources();
+ $rEPGSources = EpgService::getAll();
$rStreamArguments = StreamConfigRepository::getStreamArguments();
$rTranscodeProfiles = StreamConfigRepository::getTranscodeProfiles();
$rOnDemand = [];
diff --git a/src/public/Controllers/Admin/StreamReviewController.php b/src/public/Controllers/Admin/StreamReviewController.php
index 8cfe2039..c876aacf 100644
--- a/src/public/Controllers/Admin/StreamReviewController.php
+++ b/src/public/Controllers/Admin/StreamReviewController.php
@@ -54,7 +54,7 @@ class StreamReviewController extends BaseAdminController
foreach ($rHasBouquets as $rBouquetID) {
if (in_array($rBouquetID, $rStream['bouquets'])) {
} else {
- removeFromBouquet('stream', $rBouquetID, $rID);
+ BouquetService::removeItems('stream', $rBouquetID, $rID);
}
}
@@ -62,7 +62,7 @@ class StreamReviewController extends BaseAdminController
if (in_array($rBouquetID, $rHasBouquets)) {
} else {
$rAddBouquet[] = $rBouquetID;
- addToBouquet('stream', $rBouquetID, $rID);
+ BouquetService::addItems('stream', $rBouquetID, $rID);
}
}
}
diff --git a/src/public/Controllers/Admin/StreamViewController.php b/src/public/Controllers/Admin/StreamViewController.php
index ba4cda8d..cb5e6e81 100644
--- a/src/public/Controllers/Admin/StreamViewController.php
+++ b/src/public/Controllers/Admin/StreamViewController.php
@@ -19,7 +19,7 @@ class StreamViewController extends BaseAdminController
if (isset(RequestManager::getAll()['id']) && ($rStream = StreamRepository::getById(RequestManager::getAll()['id']))) {
} else {
- goHome();
+ AdminHelpers::goHome();
}
$rTypeString = array(1 => 'Stream', 2 => 'Movie', 3 => 'Channel', 4 => 'Station', 5 => 'Episode')[$rStream['type']];
@@ -42,7 +42,7 @@ class StreamViewController extends BaseAdminController
$rTokenData = array('session_id' => session_id(), 'expires' => $rExpires, 'stream_id' => intval(RequestManager::getAll()['id']), 'ip' => NetworkUtils::getUserIP());
$rUIToken = Encryption::encrypt(json_encode($rTokenData), SettingsManager::getAll()['live_streaming_pass'], OPENSSL_EXTRA);
- if (issecure()) {
+ if (AdminHelpers::issecure()) {
$rVServer = ServerRepository::getAll()[$rStream['vframes_server_id']];
$rImage = 'https://' . (($rVServer['domain_name'] ? $rVServer['domain_name'] : $rVServer['server_ip'])) . ':' . intval($rVServer['https_broadcast_port']) . '/admin/thumb?uitoken=' . $rUIToken;
} else {
@@ -55,7 +55,7 @@ class StreamViewController extends BaseAdminController
} else {
if ($rStream['type'] == 2 || $rStream['type'] == 5) {
$rProperties = json_decode($rStream['movie_properties'], true);
- $rImage = (!empty($rProperties['backdrop_path'][0]) ? ImageUtils::validateURL($rProperties['backdrop_path'][0], (issecure() ? 'https' : 'http')) : ImageUtils::validateURL($rProperties['movie_image'], (issecure() ? 'https' : 'http')));
+ $rImage = (!empty($rProperties['backdrop_path'][0]) ? ImageUtils::validateURL($rProperties['backdrop_path'][0], (AdminHelpers::issecure() ? 'https' : 'http')) : ImageUtils::validateURL($rProperties['movie_image'], (AdminHelpers::issecure() ? 'https' : 'http')));
if (empty($rImage)) {
} else {
diff --git a/src/public/Controllers/Admin/TicketController.php b/src/public/Controllers/Admin/TicketController.php
index 70002107..201068e2 100644
--- a/src/public/Controllers/Admin/TicketController.php
+++ b/src/public/Controllers/Admin/TicketController.php
@@ -13,7 +13,7 @@ class TicketController extends BaseAdminController {
public function index() {
$this->requirePermission();
- $rTicket = getTicket(RequestManager::getAll()['id']);
+ $rTicket = TicketRepository::getById(RequestManager::getAll()['id']);
if (!$rTicket) {
$this->redirect('tickets');
return;
diff --git a/src/public/Controllers/Admin/TicketViewController.php b/src/public/Controllers/Admin/TicketViewController.php
index bb35d028..385006d4 100644
--- a/src/public/Controllers/Admin/TicketViewController.php
+++ b/src/public/Controllers/Admin/TicketViewController.php
@@ -17,7 +17,7 @@ class TicketViewController extends BaseAdminController {
$rTicketInfo = null;
if (isset(RequestManager::getAll()['id'])) {
- $rTicketInfo = getTicket(RequestManager::getAll()['id']);
+ $rTicketInfo = TicketRepository::getById(RequestManager::getAll()['id']);
}
if (!$rTicketInfo) {
$this->redirect('tickets');
diff --git a/src/public/Controllers/Admin/UserController.php b/src/public/Controllers/Admin/UserController.php
index 9b61f483..2ea4389f 100644
--- a/src/public/Controllers/Admin/UserController.php
+++ b/src/public/Controllers/Admin/UserController.php
@@ -21,7 +21,7 @@ class UserController extends BaseAdminController {
return;
}
- $rPackages = $rUser ? getPackages($rUser['member_group_id']) : [];
+ $rPackages = $rUser ? PackageService::getAll($rUser['member_group_id']) : [];
$this->setTitle('User');
$this->render('user', compact('rUser', 'rPackages'));
diff --git a/src/public/Controllers/Admin/UseragentController.php b/src/public/Controllers/Admin/UseragentController.php
index c7573276..b40e5125 100644
--- a/src/public/Controllers/Admin/UseragentController.php
+++ b/src/public/Controllers/Admin/UseragentController.php
@@ -15,7 +15,7 @@ class UseragentController extends BaseAdminController {
$rUAArr = null;
if (isset(RequestManager::getAll()['id'])) {
- $rUAArr = getUserAgent(RequestManager::getAll()['id']);
+ $rUAArr = BlocklistService::getUserAgentById(RequestManager::getAll()['id']);
if (!$rUAArr) {
$this->redirect('useragents');
return;
diff --git a/src/public/Controllers/Admin/WatchAddController.php b/src/public/Controllers/Admin/WatchAddController.php
index 1aca0b68..27edbca8 100644
--- a/src/public/Controllers/Admin/WatchAddController.php
+++ b/src/public/Controllers/Admin/WatchAddController.php
@@ -18,7 +18,7 @@ class WatchAddController extends BaseAdminController
$rFolder = null;
$id = $this->input('id');
if (isset($id)) {
- $rFolder = getWatchFolder($id);
+ $rFolder = StreamRepository::getWatchFolder($id);
if (!$rFolder) {
$this->redirect('watch');
return;
diff --git a/src/public/Controllers/Api/AdminApiController.php b/src/public/Controllers/Api/AdminApiController.php
index ecdd8085..014aa5de 100644
--- a/src/public/Controllers/Api/AdminApiController.php
+++ b/src/public/Controllers/Api/AdminApiController.php
@@ -708,7 +708,7 @@ class AdminAPIWrapper {
$GLOBALS['rAdminUserInfo'] = UserRepository::getRegisteredUserById($rUserID);
unset($GLOBALS['rAdminUserInfo']['password']);
$rUserInfo = $GLOBALS['rAdminUserInfo'];
- $rPermissions = getPermissions($rUserInfo['member_group_id']);
+ $rPermissions = AuthRepository::getPermissions($rUserInfo['member_group_id']);
$rPermissions['advanced'] = array();
if (0 >= strlen($rUserInfo['timezone'])) {
} else {
@@ -758,7 +758,7 @@ class AdminAPIWrapper {
public static function deleteLine($rID) {
if (!(($rLine = self::getLine($rID)) && isset($rLine['data']))) {
} else {
- if (!deleteLine($rID)) {
+ if (!LineService::deleteLineById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -826,7 +826,7 @@ class AdminAPIWrapper {
public static function deleteUser($rID) {
if (!(($rUser = self::getUser($rID)) && isset($rUser['data']))) {
} else {
- if (!deleteUser($rID)) {
+ if (!UserService::deleteRegisteredUser($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -848,7 +848,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS');
}
public static function getMAG($rID) {
- if (!($rDevice = getMag($rID))) {
+ if (!($rDevice = MagService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rDevice);
@@ -884,7 +884,7 @@ class AdminAPIWrapper {
public static function deleteMAG($rID) {
if (!(($rDevice = self::getMAG($rID)) && isset($rDevice['data']))) {
} else {
- if (!deleteMAG($rID)) {
+ if (!MagService::deleteDevice($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -923,11 +923,11 @@ class AdminAPIWrapper {
if (!(($rDevice = self::getMAG($rID)) && isset($rDevice['data']))) {
return array('status' => 'STATUS_FAILURE');
}
- deleteMAG($rID, false, false, true);
+ MagService::deleteDevice($rID, false, false, true);
return array('status' => 'STATUS_SUCCESS', 'data' => self::getLine($rDevice['user_id']));
}
public static function getEnigma($rID) {
- if (!($rDevice = getEnigma($rID))) {
+ if (!($rDevice = EnigmaService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rDevice);
@@ -963,7 +963,7 @@ class AdminAPIWrapper {
public static function deleteEnigma($rID) {
if (!(($rDevice = self::getEnigma($rID)) && isset($rDevice['data']))) {
} else {
- if (!deleteEnigma($rID)) {
+ if (!EnigmaService::deleteDevice($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1002,14 +1002,14 @@ class AdminAPIWrapper {
if (!(($rDevice = self::getEnigma($rID)) && isset($rDevice['data']))) {
return array('status' => 'STATUS_FAILURE');
}
- deleteEnigma($rID, false, false, true);
+ EnigmaService::deleteDevice($rID, false, false, true);
return array('status' => 'STATUS_SUCCESS', 'data' => self::getLine($rDevice['user_id']));
}
public static function getBouquets() {
return array('status' => 'STATUS_SUCCESS', 'data' => BouquetService::getAllSimple());
}
public static function getBouquet($rID) {
- if (!($rBouquet = getBouquet($rID))) {
+ if (!($rBouquet = BouquetService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rBouquet);
@@ -1039,20 +1039,18 @@ class AdminAPIWrapper {
return $rReturn;
}
public static function deleteBouquet($rID) {
- if (!(($rBouquet = self::getBouquet($rID)) && isset($rBouquet['data']))) {
- } else {
- if (!deleteBouquet($rID)) {
- } else {
+ if (($rBouquet = self::getBouquet($rID)) && isset($rBouquet['data'])) {
+ if (BouquetService::deleteById($rID)) {
return array('status' => 'STATUS_SUCCESS');
}
}
return array('status' => 'STATUS_FAILURE');
}
public static function getAccessCodes() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getcodes());
+ return array('status' => 'STATUS_SUCCESS', 'data' => AuthRepository::getAllCodes());
}
public static function getAccessCode($rID) {
- if (!($rCode = getCode($rID))) {
+ if (!($rCode = AuthRepository::getCodeById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rCode);
@@ -1084,7 +1082,7 @@ class AdminAPIWrapper {
public static function deleteAccessCode($rID) {
if (!(($rCode = self::getAccessCode($rID)) && isset($rCode['data']))) {
} else {
- if (!removeAccessEntry($rID)) {
+ if (!AuthRepository::deleteCode($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1125,17 +1123,15 @@ class AdminAPIWrapper {
return $rReturn;
}
public static function deleteHMAC($rID) {
- if (!(($rToken = self::getHMAC($rID)) && isset($rToken['data']))) {
- } else {
- if (!validateHMAC($rID)) {
- } else {
+ if (($rToken = self::getHMAC($rID)) && isset($rToken['data'])) {
+ if (AuthRepository::deleteHMAC($rID)) {
return array('status' => 'STATUS_SUCCESS');
}
}
return array('status' => 'STATUS_FAILURE');
}
public static function getEPGs() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getEPGs());
+ return array('status' => 'STATUS_SUCCESS', 'data' => EpgService::getAll());
}
public static function getEPG($rID) {
if (!($rEPG = EpgService::getById($rID))) {
@@ -1170,7 +1166,7 @@ class AdminAPIWrapper {
public static function deleteEPG($rID) {
if (!(($rEPG = self::getEPG($rID)) && isset($rEPG['data']))) {
} else {
- if (!deleteEPG($rID)) {
+ if (!EpgService::deleteEpgById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1186,10 +1182,10 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS');
}
public static function getProviders() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getStreamProviders());
+ return array('status' => 'STATUS_SUCCESS', 'data' => ProviderService::getAll());
}
public static function getProvider($rID) {
- if (!($rProvider = getStreamProvider($rID))) {
+ if (!($rProvider = ProviderService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rProvider);
@@ -1221,7 +1217,7 @@ class AdminAPIWrapper {
public static function deleteProvider($rID) {
if (!(($rProvider = self::getProvider($rID)) && isset($rProvider['data']))) {
} else {
- if (!deleteProvider($rID)) {
+ if (!ProviderService::deleteById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1280,10 +1276,10 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function getPackages() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getPackages());
+ return array('status' => 'STATUS_SUCCESS', 'data' => PackageService::getAll());
}
public static function getPackage($rID) {
- if (!($rPackage = getPackage($rID))) {
+ if (!($rPackage = PackageService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rPackage);
@@ -1326,7 +1322,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS', 'data' => StreamConfigRepository::getTranscodeProfiles());
}
public static function getTranscodeProfile($rID) {
- if (!($rProfile = getTranscodeProfile($rID))) {
+ if (!($rProfile = StreamConfigRepository::getTranscodeProfile($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rProfile);
@@ -1358,7 +1354,7 @@ class AdminAPIWrapper {
public static function deleteTranscodeProfile($rID) {
if (!(($rProfile = self::getTranscodeProfile($rID)) && isset($rProfile['data']))) {
} else {
- if (!deleteProfile($rID)) {
+ if (!StreamConfigRepository::deleteProfile($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1369,7 +1365,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS', 'data' => BlocklistService::getRTMPIPsSimple());
}
public static function getRTMPIP($rID) {
- if (!($rIP = getRTMPIP($rID))) {
+ if (!($rIP = BlocklistService::getRTMPIPById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rIP);
@@ -1401,7 +1397,7 @@ class AdminAPIWrapper {
public static function deleteRTMPIP($rID) {
if (!(($rIP = self::getRTMPIP($rID)) && isset($rIP['data']))) {
} else {
- if (!deleteRTMPIP($rID)) {
+ if (!BlocklistService::deleteRTMPIP($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1412,7 +1408,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS', 'data' => CategoryService::getAllByType());
}
public static function getCategory($rID) {
- if (!($rCategory = getCategory($rID))) {
+ if (!($rCategory = CategoryService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rCategory);
@@ -1444,7 +1440,7 @@ class AdminAPIWrapper {
public static function deleteCategory($rID) {
if (!(($rCategory = self::getCategory($rID)) && isset($rCategory['data']))) {
} else {
- if (!deleteCategory($rID)) {
+ if (!CategoryService::deleteById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1455,7 +1451,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS', 'data' => WatchService::getWatchFolders());
}
public static function getWatchFolder($rID) {
- if (!($rFolder = getWatchFolder($rID))) {
+ if (!($rFolder = StreamRepository::getWatchFolder($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rFolder);
@@ -1487,7 +1483,7 @@ class AdminAPIWrapper {
public static function deleteWatchFolder($rID) {
if (!(($rFolder = self::getWatchFolder($rID)) && isset($rFolder['data']))) {
} else {
- if (!deleteWatchFolder($rID)) {
+ if (!StreamRepository::deleteWatchFolder($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1499,7 +1495,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS');
}
public static function getBlockedISPs() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getISPs());
+ return array('status' => 'STATUS_SUCCESS', 'data' => BlocklistService::getAllISPs());
}
public static function addBlockedISP($rData) {
if (!isset($rData['edit'])) {
@@ -1514,13 +1510,13 @@ class AdminAPIWrapper {
return $rReturn;
}
public static function deleteBlockedISP($rID) {
- if (!rdeleteBlockedISP($rID)) {
+ if (!BlocklistService::deleteBlockedISP($rID)) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
}
public static function getBlockedUAs() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getUserAgents());
+ return array('status' => 'STATUS_SUCCESS', 'data' => BlocklistService::getAllUserAgents());
}
public static function addBlockedUA($rData) {
if (!isset($rData['edit'])) {
@@ -1535,7 +1531,7 @@ class AdminAPIWrapper {
return $rReturn;
}
public static function deleteBlockedUA($rID) {
- if (!rdeleteBlockedUA($rID)) {
+ if (!BlocklistService::deleteBlockedUA($rID)) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
@@ -1556,13 +1552,13 @@ class AdminAPIWrapper {
return $rReturn;
}
public static function deleteBlockedIP($rID) {
- if (!rdeleteBlockedIP($rID)) {
+ if (!BlocklistService::deleteBlockedIP($rID)) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
}
public static function flushBlockedIPs() {
- flushIPs();
+ BlocklistService::flushIPs();
return array('status' => 'STATUS_SUCCESS');
}
public static function getStream($rID) {
@@ -1598,7 +1594,7 @@ class AdminAPIWrapper {
public static function deleteStream($rID, $rServerID = -1) {
if (!(($rStream = self::getStream($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteStream($rID, $rServerID)) {
+ if (!StreamRepository::deleteStream($rID, $rServerID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1607,9 +1603,9 @@ class AdminAPIWrapper {
}
public static function startStream($rID, $rServerID = -1) {
if ($rServerID == -1) {
- $rData = json_decode(APIRequest(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
+ $rData = json_decode(ApiClient::request(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
} else {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'stream', 'stream_ids' => array($rID), 'function' => 'start')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'stream', 'stream_ids' => array($rID), 'function' => 'start')), true);
}
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
@@ -1618,9 +1614,9 @@ class AdminAPIWrapper {
}
public static function stopStream($rID, $rServerID = -1) {
if ($rServerID == -1) {
- $rData = json_decode(APIRequest(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
+ $rData = json_decode(ApiClient::request(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
} else {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'stream', 'stream_ids' => array($rID), 'function' => 'stop')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'stream', 'stream_ids' => array($rID), 'function' => 'stop')), true);
}
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
@@ -1660,7 +1656,7 @@ class AdminAPIWrapper {
public static function deleteChannel($rID, $rServerID = -1) {
if (!(($rStream = self::getChannel($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteStream($rID, $rServerID)) {
+ if (!StreamRepository::deleteStream($rID, $rServerID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1700,7 +1696,7 @@ class AdminAPIWrapper {
public static function deleteStation($rID, $rServerID = -1) {
if (!(($rStream = self::getStation($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteStream($rID, $rServerID)) {
+ if (!StreamRepository::deleteStream($rID, $rServerID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1740,7 +1736,7 @@ class AdminAPIWrapper {
public static function deleteMovie($rID, $rServerID = -1) {
if (!(($rStream = self::getMovie($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteStream($rID, $rServerID)) {
+ if (!StreamRepository::deleteStream($rID, $rServerID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1749,9 +1745,9 @@ class AdminAPIWrapper {
}
public static function startMovie($rID, $rServerID = -1) {
if ($rServerID == -1) {
- $rData = json_decode(APIRequest(array('action' => 'vod', 'sub' => 'start', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
+ $rData = json_decode(ApiClient::request(array('action' => 'vod', 'sub' => 'start', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
} else {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'vod', 'stream_ids' => array($rID), 'function' => 'start')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'vod', 'stream_ids' => array($rID), 'function' => 'start')), true);
}
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
@@ -1760,9 +1756,9 @@ class AdminAPIWrapper {
}
public static function stopMovie($rID, $rServerID = -1) {
if ($rServerID == -1) {
- $rData = json_decode(APIRequest(array('action' => 'vod', 'sub' => 'stop', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
+ $rData = json_decode(ApiClient::request(array('action' => 'vod', 'sub' => 'stop', 'stream_ids' => array($rID), 'servers' => array_keys(ServerRepository::getAll()))), true);
} else {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'vod', 'stream_ids' => array($rID), 'function' => 'stop')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'vod', 'stream_ids' => array($rID), 'function' => 'stop')), true);
}
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
@@ -1802,7 +1798,7 @@ class AdminAPIWrapper {
public static function deleteEpisode($rID, $rServerID = -1) {
if (!(($rStream = self::getEpisode($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteStream($rID, $rServerID)) {
+ if (!StreamRepository::deleteStream($rID, $rServerID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1810,7 +1806,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function getSeries($rID) {
- if (!($rSeries = getSerie($rID))) {
+ if (!($rSeries = SeriesService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rSeries);
@@ -1842,7 +1838,7 @@ class AdminAPIWrapper {
public static function deleteSeries($rID) {
if (!(($rStream = self::getSeries($rID)) && isset($rStream['data']))) {
} else {
- if (!deleteSeries($rID)) {
+ if (!SeriesService::deleteSeriesById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -1850,15 +1846,17 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function getServers() {
+ global $rPermissions;
return array('status' => 'STATUS_SUCCESS', 'data' => ServerRepository::getStreamingSimple($rPermissions));
}
public static function getServer($rID) {
- if (!($rServer = getStreamingServersByID($rID))) {
+ if (!($rServer = ServerRepository::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rServer);
}
public static function installServer($rData) {
+ global $rPermissions;
if (!(empty($rData['type']) || empty($rData['ssh_port']) || empty($rData['root_username']) || empty($rData['root_password']))) {
if (!($rData['type'] == 1 && (empty($rData['type']) || empty($rData['ssh_port'])))) {
$rReturn = parseerror(ServerService::install($rData, ServerRepository::getStreamingSimple($rPermissions, 'all'), ServerRepository::getProxySimple($rPermissions)));
@@ -1908,7 +1906,7 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function getSettings() {
- return array('status' => 'STATUS_SUCCESS', 'data' => getSettings());
+ return array('status' => 'STATUS_SUCCESS', 'data' => SettingsManager::getAll());
}
public static function editSettings($rData) {
$rReturn = parseerror(SettingsService::edit($rData));
@@ -1917,7 +1915,7 @@ class AdminAPIWrapper {
}
public static function getStats($rServerID) {
global $db;
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'stats')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'stats')), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
@@ -1961,60 +1959,60 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function getFPMStatus($rServerID) {
- $rData = systemapirequest($rServerID, array('action' => 'fpm_status'));
+ $rData = ApiClient::systemRequest($rServerID, array('action' => 'fpm_status'));
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function getRTMPStats($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'rtmp_stats')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'rtmp_stats')), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function getFreeSpace($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'get_free_space')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'get_free_space')), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function getPIDs($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'get_pids')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'get_pids')), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function getCertificateInfo($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'get_certificate_info')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'get_certificate_info')), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS', 'data' => $rData);
}
public static function reloadNGINX($rServerID) {
- systemapirequest($rServerID, array('action' => 'reload_nginx'));
+ ApiClient::systemRequest($rServerID, array('action' => 'reload_nginx'));
return array('status' => 'STATUS_SUCCESS');
}
public static function clearTemp($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'free_temp')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'free_temp')), true);
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
}
public static function clearStreams($rServerID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'free_streams')), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'free_streams')), true);
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
}
public static function getDirectory($rServerID, $rDirectory) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'scandir', 'dir' => $rDirectory)), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'scandir', 'dir' => $rDirectory)), true);
if (!$rData) {
return array('status' => 'STATUS_FAILURE');
}
@@ -2025,14 +2023,14 @@ class AdminAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function killPID($rServerID, $rPID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'kill_pid', 'pid' => intval($rPID))), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'kill_pid', 'pid' => intval($rPID))), true);
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
}
return array('status' => 'STATUS_SUCCESS');
}
public static function killConnection($rServerID, $rActivityID) {
- $rData = json_decode(systemapirequest($rServerID, array('action' => 'closeConnection', 'activity_id' => intval($rActivityID))), true);
+ $rData = json_decode(ApiClient::systemRequest($rServerID, array('action' => 'closeConnection', 'activity_id' => intval($rActivityID))), true);
if (!$rData['result']) {
return array('status' => 'STATUS_FAILURE');
}
diff --git a/src/public/Controllers/Api/ResellerRestApiController.php b/src/public/Controllers/Api/ResellerRestApiController.php
index f1a4df61..287c8e76 100644
--- a/src/public/Controllers/Api/ResellerRestApiController.php
+++ b/src/public/Controllers/Api/ResellerRestApiController.php
@@ -266,7 +266,7 @@ class ResellerAPIWrapper {
}
$rPackages = array();
$rOverride = json_decode($rUserInfo['override_packages'], true);
- foreach (getPackages($rUserInfo['member_group_id']) as $rPackage) {
+ foreach (PackageService::getAll($rUserInfo['member_group_id']) as $rPackage) {
if (isset($rOverride[$rPackage['id']]['official_credits']) && 0 < strlen($rOverride[$rPackage['id']]['official_credits'])) {
$rPackage['official_credits'] = intval($rOverride[$rPackage['id']]['official_credits']);
} else {
@@ -313,7 +313,7 @@ class ResellerAPIWrapper {
public static function deleteLine($rID) {
if (!UserRepository::getLineById($rID)) {
} else {
- if (!deleteLine($rID)) {
+ if (!LineService::deleteLineById($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -335,7 +335,7 @@ class ResellerAPIWrapper {
return array('status' => 'STATUS_SUCCESS');
}
public static function getMAG($rID) {
- if (!($rDevice = getMag($rID))) {
+ if (!($rDevice = MagService::getById($rID))) {
} else {
if (!Authorization::check('line', $rDevice['user_id'])) {
} else {
@@ -357,7 +357,7 @@ class ResellerAPIWrapper {
return $rReturn;
}
public static function editMAG($rID, $rData) {
- if (!getMag($rID)) {
+ if (!MagService::getById($rID)) {
return array('status' => 'STATUS_FAILURE');
}
$rData['edit'] = $rID;
@@ -373,9 +373,9 @@ class ResellerAPIWrapper {
return $rReturn;
}
public static function deleteMAG($rID) {
- if (!getMag($rID)) {
+ if (!MagService::getById($rID)) {
} else {
- if (!deleteMAG($rID)) {
+ if (!MagService::deleteDevice($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -383,14 +383,14 @@ class ResellerAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function disableMAG($rID) {
- if (!($rDevice = getMag($rID))) {
+ if (!($rDevice = MagService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
self::$db->query('UPDATE `lines` SET `enabled` = 0 WHERE `id` = ?;', $rDevice['user_id']);
return array('status' => 'STATUS_SUCCESS');
}
public static function enableMAG($rID) {
- if (!($rDevice = getMag($rID))) {
+ if (!($rDevice = MagService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
self::$db->query('UPDATE `lines` SET `enabled` = 1 WHERE `id` = ?;', $rDevice['user_id']);
@@ -398,14 +398,14 @@ class ResellerAPIWrapper {
}
public static function convertMAG($rID) {
global $db;
- if (!($rDevice = getMag($rID))) {
+ if (!($rDevice = MagService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
- deleteMAG($rID, false, false, true);
+ MagService::deleteDevice($rID, false, false, true);
return array('status' => 'STATUS_SUCCESS', 'data' => UserRepository::getLineById($rDevice['user_id']));
}
public static function getEnigma($rID) {
- if (!($rDevice = getEnigma($rID))) {
+ if (!($rDevice = EnigmaService::getById($rID))) {
} else {
if (!Authorization::check('line', $rDevice['user_id'])) {
} else {
@@ -427,7 +427,7 @@ class ResellerAPIWrapper {
return $rReturn;
}
public static function editEnigma($rID, $rData) {
- if (!getEnigma($rID)) {
+ if (!EnigmaService::getById($rID)) {
return array('status' => 'STATUS_FAILURE');
}
$rData['edit'] = $rID;
@@ -443,9 +443,9 @@ class ResellerAPIWrapper {
return $rReturn;
}
public static function deleteEnigma($rID) {
- if (!getEnigma($rID)) {
+ if (!EnigmaService::getById($rID)) {
} else {
- if (!deleteEnigma($rID)) {
+ if (!EnigmaService::deleteDevice($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
@@ -453,14 +453,14 @@ class ResellerAPIWrapper {
return array('status' => 'STATUS_FAILURE');
}
public static function disableEnigma($rID) {
- if (!($rDevice = getEnigma($rID))) {
+ if (!($rDevice = EnigmaService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
self::$db->query('UPDATE `lines` SET `enabled` = 0 WHERE `id` = ?;', $rDevice['user_id']);
return array('status' => 'STATUS_SUCCESS');
}
public static function enableEnigma($rID) {
- if (!($rDevice = getEnigma($rID))) {
+ if (!($rDevice = EnigmaService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
self::$db->query('UPDATE `lines` SET `enabled` = 1 WHERE `id` = ?;', $rDevice['user_id']);
@@ -468,10 +468,10 @@ class ResellerAPIWrapper {
}
public static function convertEnigma($rID) {
global $db;
- if (!($rDevice = getEnigma($rID))) {
+ if (!($rDevice = EnigmaService::getById($rID))) {
return array('status' => 'STATUS_FAILURE');
}
- deleteEnigma($rID, false, false, true);
+ EnigmaService::deleteDevice($rID, false, false, true);
return array('status' => 'STATUS_SUCCESS', 'data' => UserRepository::getLineById($rDevice['user_id']));
}
public static function getUser($rID) {
@@ -507,7 +507,7 @@ class ResellerAPIWrapper {
public static function deleteUser($rID) {
if (!(($rUser = self::getUser($rID)) && isset($rUser['data']))) {
} else {
- if (!deleteUser($rID)) {
+ if (!UserService::deleteRegisteredUser($rID)) {
} else {
return array('status' => 'STATUS_SUCCESS');
}
diff --git a/src/public/Controllers/Player/EpisodesController.php b/src/public/Controllers/Player/EpisodesController.php
index 6ff6b0ce..b121a23e 100644
--- a/src/public/Controllers/Player/EpisodesController.php
+++ b/src/public/Controllers/Player/EpisodesController.php
@@ -16,13 +16,13 @@ class EpisodesController extends BasePlayerController
{
global $db, $rUserInfo;
- if (($rSeries = getSerie(RequestManager::getAll()['id'])) && in_array(RequestManager::getAll()['id'], $rUserInfo['series_ids'])) {
+ if (($rSeries = SeriesService::getById(RequestManager::getAll()['id'])) && in_array(RequestManager::getAll()['id'], $rUserInfo['series_ids'])) {
$rDomainName = DomainResolver::resolve(SERVER_ID, !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443);
$rTMDB = null;
if ($rSeries['tmdb_id']) {
if (!file_exists(TMP_PATH . 'tmdb_' . $rSeries['tmdb_id'])) {
- $rTMDB = getSeriesTMDB($rSeries['tmdb_id']);
+ $rTMDB = TMDbService::getSeries($rSeries['tmdb_id']);
if ($rTMDB) {
file_put_contents(TMP_PATH . 'tmdb_' . $rSeries['tmdb_id'], igbinary_serialize($rTMDB));
@@ -84,7 +84,7 @@ class EpisodesController extends BasePlayerController
if (!$rSeries['tmdb_id']) {
} else {
if (!file_exists(TMP_PATH . 'tmdb_' . $rSeries['tmdb_id'] . '_' . $rSeasonNo)) {
- $rSeason = getSeasonTMDB($rSeries['tmdb_id'], $rSeasonNo);
+ $rSeason = TMDbService::getSeason($rSeries['tmdb_id'], $rSeasonNo);
if (!$rSeason) {
} else {
diff --git a/src/public/Controllers/Player/PlayerLoginController.php b/src/public/Controllers/Player/PlayerLoginController.php
index 5b6ec59c..511e3f88 100644
--- a/src/public/Controllers/Player/PlayerLoginController.php
+++ b/src/public/Controllers/Player/PlayerLoginController.php
@@ -37,9 +37,10 @@ class PlayerLoginController
'You are not allowed to access this player.',
];
- // Bootstrap: загружаем includes/admin.php для БД, settings,
+ // Bootstrap: загружаем ядро для БД, settings,
// destroySession() и других глобальных зависимостей.
- require_once MAIN_HOME . 'includes/admin.php';
+ require_once MAIN_HOME . 'bootstrap.php';
+ XC_Bootstrap::boot(XC_Bootstrap::CONTEXT_ADMIN);
// Start session
if (session_status() === PHP_SESSION_NONE && !headers_sent()) {
@@ -47,7 +48,7 @@ class PlayerLoginController
}
// Destroy existing session
- destroySession('player');
+ SessionManager::clearContext('player');
$_STATUS = null;
diff --git a/src/public/Controllers/Player/PlayerLogoutController.php b/src/public/Controllers/Player/PlayerLogoutController.php
index 2ae66af6..fb387904 100644
--- a/src/public/Controllers/Player/PlayerLogoutController.php
+++ b/src/public/Controllers/Player/PlayerLogoutController.php
@@ -14,7 +14,7 @@ class PlayerLogoutController extends BasePlayerController
{
public function index()
{
- destroySession('player');
+ SessionManager::clearContext('player');
header('Location: login');
exit();
}
diff --git a/src/public/Controllers/Player/PlayerMovieController.php b/src/public/Controllers/Player/PlayerMovieController.php
index 2d592219..990ce173 100644
--- a/src/public/Controllers/Player/PlayerMovieController.php
+++ b/src/public/Controllers/Player/PlayerMovieController.php
@@ -29,7 +29,7 @@ class PlayerMovieController extends BasePlayerController
if ($rProperties['tmdb_id']) {
if (!file_exists(TMP_PATH . 'tmdb_' . $rProperties['tmdb_id'])) {
- $rTMDB = json_decode(json_encode(getMovieTMDB($rProperties['tmdb_id'])), true);
+ $rTMDB = json_decode(json_encode(TMDbService::getMovie($rProperties['tmdb_id'])), true);
if ($rTMDB) {
file_put_contents(TMP_PATH . 'tmdb_' . $rProperties['tmdb_id'], igbinary_serialize($rTMDB));
diff --git a/src/public/Controllers/Player/PlayerProfileController.php b/src/public/Controllers/Player/PlayerProfileController.php
index 7bf2a204..712f4f10 100644
--- a/src/public/Controllers/Player/PlayerProfileController.php
+++ b/src/public/Controllers/Player/PlayerProfileController.php
@@ -29,7 +29,7 @@ class PlayerProfileController extends BasePlayerController
if (!isset(RequestManager::getAll()['bouquet_order'])) {
} else {
$rBouquetOrder = json_decode(RequestManager::getAll()['bouquet_order'], true);
- $rUserInfo['bouquet'] = array_map('intval', sortArrayByArray($rUserInfo['bouquet'], $rBouquetOrder));
+ $rUserInfo['bouquet'] = array_map('intval', AdminHelpers::sortArrayByArray($rUserInfo['bouquet'], $rBouquetOrder));
$db->query('UPDATE `lines` SET `bouquet` = ? WHERE `id` = ?;', '[' . implode(',', $rUserInfo['bouquet']) . ']', $rUserInfo['id']);
if (!SettingsManager::getAll()['enable_cache']) {
diff --git a/src/public/Controllers/Reseller/BaseResellerController.php b/src/public/Controllers/Reseller/BaseResellerController.php
index 01da974d..0268e963 100644
--- a/src/public/Controllers/Reseller/BaseResellerController.php
+++ b/src/public/Controllers/Reseller/BaseResellerController.php
@@ -22,21 +22,19 @@ class BaseResellerController extends BaseAdminController
protected $scope = 'reseller';
/**
- * Проверка прав доступа реселлера (checkResellerPermissions).
- * При отказе — goHome() + exit.
+ * Проверка прав доступа реселлера.
+ * При отказе — redirect на главную + exit.
*/
protected function requirePermission()
{
- if (function_exists('checkResellerPermissions') && !checkResellerPermissions()) {
- if (function_exists('goHome')) {
- goHome();
- }
+ if (!PageAuthorization::checkResellerPermissions()) {
+ AdminHelpers::goHome();
exit;
}
}
/**
- * Проверка расширенных прав реселлера (hasPermissions).
+ * Проверка расширенных прав реселлера.
* Reseller permissions загружены через getGroupPermissions().
*
* @param string $type Тип прав
@@ -44,10 +42,8 @@ class BaseResellerController extends BaseAdminController
*/
protected function requireAdvPermission($type, $key)
{
- if (class_exists('Authorization') && !Authorization::check($type, $key)) {
- if (function_exists('goHome')) {
- goHome();
- }
+ if (!Authorization::check($type, $key)) {
+ AdminHelpers::goHome();
exit;
}
}
diff --git a/src/public/Controllers/Reseller/ResellerDashboardController.php b/src/public/Controllers/Reseller/ResellerDashboardController.php
index 8dd5cd2e..d22dc3b0 100644
--- a/src/public/Controllers/Reseller/ResellerDashboardController.php
+++ b/src/public/Controllers/Reseller/ResellerDashboardController.php
@@ -39,7 +39,7 @@ class ResellerDashboardController extends BaseResellerController
$rNotice = preg_replace("#(<[^>]+?)style[\\x00-\\x20]*=[\\x00-\\x20]*[`'\"]*.*?s[\\x00-\\x20]*c[\\x00-\\x20]*r[\\x00-\\x20]*i[\\x00-\\x20]*p[\\x00-\\x20]*t[\\x00-\\x20]*:*[^>]*+>#iu", '$1>', $rNotice);
// Recent activity
- $rPackages = getPackages();
+ $rPackages = PackageService::getAll();
global $db;
$rAllReports = array_merge(array($rUserInfo['id']), $rPermissions['all_reports'] ?? []);
$db->query('SELECT * FROM `users_logs` LEFT JOIN `users` ON `users`.`id` = `users_logs`.`owner` WHERE `users_logs`.`owner` IN (' . implode(',', array_map('intval', $rAllReports)) . ') ORDER BY `date` DESC LIMIT 250;');
@@ -86,7 +86,7 @@ class ResellerDashboardController extends BaseResellerController
}
// Expiring lines
- $rExpiringLines = getExpiring() ?: [];
+ $rExpiringLines = LineService::getExpiring() ?: [];
$this->render('dashboard', [
'rRegisteredUsers' => $rRegisteredUsers,
diff --git a/src/public/Controllers/Reseller/ResellerEditProfileController.php b/src/public/Controllers/Reseller/ResellerEditProfileController.php
index 03ff9ba7..7e7d1bb9 100644
--- a/src/public/Controllers/Reseller/ResellerEditProfileController.php
+++ b/src/public/Controllers/Reseller/ResellerEditProfileController.php
@@ -16,11 +16,11 @@ class ResellerEditProfileController extends BaseResellerController
$this->setTitle('Edit Profile');
$data = [
- 'timezones' => TimeZoneList(),
+ 'timezones' => AdminHelpers::TimeZoneList(),
];
// Find API code for this user's group
- foreach (getcodes() as $rCode) {
+ foreach (AuthRepository::getAllCodes() as $rCode) {
if ($rCode['type'] == 4 && in_array($GLOBALS['rUserInfo']['member_group_id'], json_decode($rCode['groups'], true) ?: [])) {
$data['apiCode'] = $rCode;
$servers = ServerRepository::getAll();
diff --git a/src/public/Controllers/Reseller/ResellerEnigmaController.php b/src/public/Controllers/Reseller/ResellerEnigmaController.php
index 9e0294f8..8c9f3368 100644
--- a/src/public/Controllers/Reseller/ResellerEnigmaController.php
+++ b/src/public/Controllers/Reseller/ResellerEnigmaController.php
@@ -23,18 +23,18 @@ class ResellerEnigmaController extends BaseResellerController
$rOrigPackage = null;
if (isset($rRequest['id'])) {
- $rDevice = getEnigma($rRequest['id']);
+ $rDevice = EnigmaService::getById($rRequest['id']);
if (!($rDevice && $rDevice['user'] && $rDevice['user']['is_e2'] && Authorization::check('line', $rDevice['user']['id']))) {
- goHome();
+ AdminHelpers::goHome();
return;
}
$rLine = $rDevice['user'];
if ($rLine['package_id'] > 0) {
- $rOrigPackage = getPackage($rLine['package_id']);
+ $rOrigPackage = PackageService::getById($rLine['package_id']);
}
}
- $rPackages = getPackages($rUserInfo['member_group_id'], 'e2') ?: [];
+ $rPackages = PackageService::getAll($rUserInfo['member_group_id'], 'e2') ?: [];
$this->render('enigma', [
'rDevice' => $rDevice,
diff --git a/src/public/Controllers/Reseller/ResellerLineController.php b/src/public/Controllers/Reseller/ResellerLineController.php
index f957d10b..49ade794 100644
--- a/src/public/Controllers/Reseller/ResellerLineController.php
+++ b/src/public/Controllers/Reseller/ResellerLineController.php
@@ -24,15 +24,15 @@ class ResellerLineController extends BaseResellerController
if (isset($rRequest['id'])) {
$rLine = UserRepository::getLineById($rRequest['id']);
if (!$rLine || $rLine['is_mag'] || $rLine['is_e2'] || !Authorization::check('line', $rLine['id'])) {
- goHome();
+ AdminHelpers::goHome();
return;
}
if ($rLine['package_id'] > 0) {
- $rOrigPackage = getPackage($rLine['package_id']);
+ $rOrigPackage = PackageService::getById($rLine['package_id']);
}
}
- $rPackages = getPackages($rUserInfo['member_group_id'], 'line') ?: [];
+ $rPackages = PackageService::getAll($rUserInfo['member_group_id'], 'line') ?: [];
$this->render('line', [
'rLine' => $rLine,
diff --git a/src/public/Controllers/Reseller/ResellerLogoutController.php b/src/public/Controllers/Reseller/ResellerLogoutController.php
index 87e27595..6329b9d5 100644
--- a/src/public/Controllers/Reseller/ResellerLogoutController.php
+++ b/src/public/Controllers/Reseller/ResellerLogoutController.php
@@ -13,7 +13,7 @@ class ResellerLogoutController extends BaseResellerController
{
public function index()
{
- destroySession('reseller');
+ SessionManager::clearContext('reseller');
$this->redirect('./login');
}
}
diff --git a/src/public/Controllers/Reseller/ResellerMagController.php b/src/public/Controllers/Reseller/ResellerMagController.php
index ca613d24..14ad4f4b 100644
--- a/src/public/Controllers/Reseller/ResellerMagController.php
+++ b/src/public/Controllers/Reseller/ResellerMagController.php
@@ -20,20 +20,20 @@ class ResellerMagController extends BaseResellerController
$rOrigPackage = null;
if (isset($GLOBALS['rRequest']['id'])) {
- $rDevice = getMag($GLOBALS['rRequest']['id']);
+ $rDevice = MagService::getById($GLOBALS['rRequest']['id']);
if (!$rDevice || !$rDevice['user'] || !$rDevice['user']['is_mag'] || !Authorization::check('line', $rDevice['user']['id'])) {
- goHome();
+ AdminHelpers::goHome();
}
$rLine = $rDevice['user'];
if ($rLine['package_id'] > 0) {
- $rOrigPackage = getPackage($rLine['package_id']);
+ $rOrigPackage = PackageService::getById($rLine['package_id']);
}
}
- $rPackages = getPackages($GLOBALS['rUserInfo']['member_group_id'], 'mag') ?: [];
+ $rPackages = PackageService::getAll($GLOBALS['rUserInfo']['member_group_id'], 'mag') ?: [];
$this->setTitle('MAG Device');
$this->render('mag', [
diff --git a/src/public/Controllers/Reseller/ResellerTableController.php b/src/public/Controllers/Reseller/ResellerTableController.php
index a324cc25..2516dd61 100644
--- a/src/public/Controllers/Reseller/ResellerTableController.php
+++ b/src/public/Controllers/Reseller/ResellerTableController.php
@@ -41,9 +41,10 @@ class ResellerTableController extends BaseResellerController
if ($db->num_rows() != 0) {
$rUserID = $db->get_row()['id'];
$rIsAPI = true;
- require_once MAIN_HOME . 'includes/admin.php';
+ require_once MAIN_HOME . 'bootstrap.php';
+ XC_Bootstrap::boot(XC_Bootstrap::CONTEXT_ADMIN);
$rUserInfo = UserRepository::getRegisteredUserById($rUserID);
- $rPermissions = array_merge(getPermissions($rUserInfo['member_group_id']), getGroupPermissions($rUserInfo['id']));
+ $rPermissions = array_merge(AuthRepository::getPermissions($rUserInfo['member_group_id']), AuthRepository::getGroupPermissions($rUserInfo['id']));
$rPermissions['direct_reports'] = $rPermissions['direct_reports'] ?? [];
$rPermissions['all_reports'] = $rPermissions['all_reports'] ?? [];
$rPermissions['stream_ids'] = $rPermissions['stream_ids'] ?? [];
diff --git a/src/public/Controllers/Reseller/ResellerTicketController.php b/src/public/Controllers/Reseller/ResellerTicketController.php
index 90571d40..3c54d81c 100644
--- a/src/public/Controllers/Reseller/ResellerTicketController.php
+++ b/src/public/Controllers/Reseller/ResellerTicketController.php
@@ -20,9 +20,9 @@ class ResellerTicketController extends BaseResellerController
$rTicketInfo = null;
if (isset($rRequest['id'])) {
- $rTicketInfo = getTicket($rRequest['id']);
+ $rTicketInfo = TicketRepository::getById($rRequest['id']);
if (!$rTicketInfo) {
- goHome();
+ AdminHelpers::goHome();
return;
}
if (!Authorization::check('user', $rTicketInfo['member_id'])) {
diff --git a/src/public/Controllers/Reseller/ResellerTicketViewController.php b/src/public/Controllers/Reseller/ResellerTicketViewController.php
index 65b8c66e..8a546a88 100644
--- a/src/public/Controllers/Reseller/ResellerTicketViewController.php
+++ b/src/public/Controllers/Reseller/ResellerTicketViewController.php
@@ -17,8 +17,8 @@ class ResellerTicketViewController extends BaseResellerController
$rRequest = RequestManager::getAll();
- if (!isset($rRequest['id']) || !($rTicketInfo = getTicket($rRequest['id']))) {
- goHome();
+ if (!isset($rRequest['id']) || !($rTicketInfo = TicketRepository::getById($rRequest['id']))) {
+ AdminHelpers::goHome();
return;
}
diff --git a/src/public/Controllers/Reseller/ResellerTicketsController.php b/src/public/Controllers/Reseller/ResellerTicketsController.php
index 4b6b04df..3e61947d 100644
--- a/src/public/Controllers/Reseller/ResellerTicketsController.php
+++ b/src/public/Controllers/Reseller/ResellerTicketsController.php
@@ -20,7 +20,7 @@ class ResellerTicketsController extends BaseResellerController
$this->render('tickets', [
'statusArray' => $statusArray,
- 'tickets' => getTickets($GLOBALS['rUserInfo']['id']),
+ 'tickets' => TicketRepository::getAll($GLOBALS['rUserInfo']['id']),
]);
}
}
diff --git a/src/public/Controllers/Reseller/ResellerUserController.php b/src/public/Controllers/Reseller/ResellerUserController.php
index b709ea89..2ba76e16 100644
--- a/src/public/Controllers/Reseller/ResellerUserController.php
+++ b/src/public/Controllers/Reseller/ResellerUserController.php
@@ -24,7 +24,7 @@ class ResellerUserController extends BaseResellerController
$rUser = UserRepository::getRegisteredUserById($rRequest['id']);
if (!$rUser || $rRequest['id'] == $rUserInfo['id']) {
- goHome();
+ AdminHelpers::goHome();
}
// Remove edited user from reports arrays so they don't appear in owner dropdown
diff --git a/src/public/Views/admin/api.php b/src/public/Views/admin/api.php
index aa46e96c..92f71389 100644
--- a/src/public/Views/admin/api.php
+++ b/src/public/Views/admin/api.php
@@ -35,12 +35,12 @@ if (isset($_SESSION['hash'])) {
}
if (count($rServerIDs) > 0) {
- echo APIRequest(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs));
+ echo ApiClient::request(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs));
exit();
}
} else {
- echo APIRequest(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID)));
+ echo ApiClient::request(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID)));
exit();
}
@@ -56,13 +56,13 @@ if (isset($_SESSION['hash'])) {
}
$rCommand = array('action' => 'force_stream', 'stream_id' => $rStreamID, 'force_id' => $rForceID);
- echo json_encode(AsyncAPIRequest($rServerIDs, $rCommand));
+ echo json_encode(ApiClient::asyncRequest($rServerIDs, $rCommand));
exit();
}
if ($rSub == 'delete') {
- deleteStream($rStreamID, $rServerID, false);
+ StreamRepository::deleteStream($rStreamID, $rServerID, false);
echo json_encode(array('result' => true));
exit();
@@ -124,18 +124,18 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rServerIDs)) {
} else {
- echo APIRequest(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs, 'force' => true));
+ echo ApiClient::request(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs, 'force' => true));
exit();
}
} else {
- echo APIRequest(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID), 'force' => true));
+ echo ApiClient::request(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID), 'force' => true));
exit();
}
} else {
if ($rSub == 'delete') {
- deleteStream($rStreamID, $rServerID, true);
+ StreamRepository::deleteStream($rStreamID, $rServerID, true);
echo json_encode(array('result' => true));
exit();
@@ -197,18 +197,18 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rServerIDs)) {
} else {
- echo APIRequest(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs, 'force' => true));
+ echo ApiClient::request(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => $rServerIDs, 'force' => true));
exit();
}
} else {
- echo APIRequest(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID), 'force' => true));
+ echo ApiClient::request(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => array($rStreamID), 'servers' => array($rServerID), 'force' => true));
exit();
}
} else {
if ($rSub == 'delete') {
- deleteStream($rStreamID, $rServerID, true);
+ StreamRepository::deleteStream($rStreamID, $rServerID, true);
echo json_encode(array('result' => true));
exit();
@@ -259,7 +259,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteLine($rUserID);
+ LineService::deleteLineById($rUserID);
echo json_encode(array('result' => true));
exit();
@@ -346,7 +346,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'process') {
if (Authorization::check('adv', 'process_monitor')) {
- systemapirequest(RequestManager::getAll()['server'], array('action' => 'kill_pid', 'pid' => intval(RequestManager::getAll()['pid'])));
+ ApiClient::systemRequest(RequestManager::getAll()['server'], array('action' => 'kill_pid', 'pid' => intval(RequestManager::getAll()['pid'])));
echo json_encode(array('result' => true));
exit();
@@ -390,7 +390,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteUser(RequestManager::getAll()['user_id'], false, false, $rUserInfo['id']);
+ UserService::deleteRegisteredUser(RequestManager::getAll()['user_id'], false, false, $rUserInfo['id']);
echo json_encode(array('result' => true));
exit();
@@ -424,7 +424,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteTicket(RequestManager::getAll()['ticket_id']);
+ TicketRepository::deleteById(RequestManager::getAll()['ticket_id']);
echo json_encode(array('result' => true));
exit();
@@ -456,10 +456,10 @@ if (isset($_SESSION['hash'])) {
if (RequestManager::getAll()['action'] == 'mag') {
if (Authorization::check('adv', 'edit_mag')) {
$rSub = RequestManager::getAll()['sub'];
- $rMagDetails = getMag(intval(RequestManager::getAll()['mag_id']));
+ $rMagDetails = MagService::getById(intval(RequestManager::getAll()['mag_id']));
if ($rSub == 'delete') {
- deleteMAG(RequestManager::getAll()['mag_id']);
+ MagService::deleteDevice(RequestManager::getAll()['mag_id']);
echo json_encode(array('result' => true));
exit();
@@ -498,7 +498,7 @@ if (isset($_SESSION['hash'])) {
}
if ($rSub == 'convert') {
- deleteMAG(RequestManager::getAll()['mag_id'], false, false, true);
+ MagService::deleteDevice(RequestManager::getAll()['mag_id'], false, false, true);
echo json_encode(array('result' => true, 'line_id' => $rMagDetails['user']['id']));
exit();
@@ -534,10 +534,10 @@ if (isset($_SESSION['hash'])) {
if (RequestManager::getAll()['action'] == 'enigma') {
if (Authorization::check('adv', 'edit_e2')) {
$rSub = RequestManager::getAll()['sub'];
- $rE2Details = getEnigma(intval(RequestManager::getAll()['e2_id']));
+ $rE2Details = EnigmaService::getById(intval(RequestManager::getAll()['e2_id']));
if ($rSub == 'delete') {
- deleteEnigma(RequestManager::getAll()['e2_id']);
+ EnigmaService::deleteDevice(RequestManager::getAll()['e2_id']);
echo json_encode(array('result' => true));
exit();
@@ -576,7 +576,7 @@ if (isset($_SESSION['hash'])) {
}
if ($rSub == 'convert') {
- deleteEnigma(RequestManager::getAll()['e2_id'], false, false, true);
+ EnigmaService::deleteDevice(RequestManager::getAll()['e2_id'], false, false, true);
echo json_encode(array('result' => true, 'line_id' => $rE2Details['user']['id']));
exit();
@@ -691,7 +691,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteEPG(RequestManager::getAll()['epg_id']);
+ EpgService::deleteEpgById(RequestManager::getAll()['epg_id']);
echo json_encode(array('result' => true));
exit();
@@ -718,7 +718,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteProvider(RequestManager::getAll()['id']);
+ ProviderService::deleteById(RequestManager::getAll()['id']);
echo json_encode(array('result' => true));
exit();
@@ -745,7 +745,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteProfile(RequestManager::getAll()['profile_id']);
+ StreamConfigRepository::deleteProfile(RequestManager::getAll()['profile_id']);
echo json_encode(array('result' => true));
exit();
@@ -765,7 +765,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteSeries(RequestManager::getAll()['series_id']);
+ SeriesService::deleteSeriesById(RequestManager::getAll()['series_id']);
echo json_encode(array('result' => true));
exit();
@@ -794,7 +794,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'kill_plex') {
if (Authorization::check('adv', 'folder_watch')) {
- killPlexSync();
+ ServerService::killPlexSync();
echo json_encode(array('result' => true));
exit();
@@ -809,14 +809,14 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteWatchFolder(RequestManager::getAll()['folder_id']);
+ StreamRepository::deleteWatchFolder(RequestManager::getAll()['folder_id']);
echo json_encode(array('result' => true));
exit();
}
if ($rSub == 'force') {
- $rFolder = getWatchFolder(RequestManager::getAll()['folder_id']);
+ $rFolder = StreamRepository::getWatchFolder(RequestManager::getAll()['folder_id']);
if ($rFolder) {
WatchService::forceWatch($rFolder['server_id'], $rFolder['id']);
@@ -844,14 +844,14 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteWatchFolder(RequestManager::getAll()['folder_id']);
+ StreamRepository::deleteWatchFolder(RequestManager::getAll()['folder_id']);
echo json_encode(array('result' => true));
exit();
}
if ($rSub == 'force') {
- $rFolder = getWatchFolder(RequestManager::getAll()['folder_id']);
+ $rFolder = StreamRepository::getWatchFolder(RequestManager::getAll()['folder_id']);
if ($rFolder) {
PlexService::forcePlex($rFolder['server_id'], $rFolder['id']);
@@ -879,7 +879,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- rdeleteBlockedUA(RequestManager::getAll()['ua_id']);
+ BlocklistService::deleteBlockedUA(RequestManager::getAll()['ua_id']);
echo json_encode(array('result' => true));
exit();
@@ -899,7 +899,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- rdeleteBlockedISP(RequestManager::getAll()['isp_id']);
+ BlocklistService::deleteBlockedISP(RequestManager::getAll()['isp_id']);
echo json_encode(array('result' => true));
exit();
@@ -940,7 +940,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- rdeleteBlockedIP(RequestManager::getAll()['ip']);
+ BlocklistService::deleteBlockedIP(RequestManager::getAll()['ip']);
echo json_encode(array('result' => true));
exit();
@@ -960,7 +960,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteRTMPIP(RequestManager::getAll()['ip']);
+ BlocklistService::deleteRTMPIP(RequestManager::getAll()['ip']);
echo json_encode(array('result' => true));
exit();
@@ -1086,7 +1086,7 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rStreamIDs)) {
} else {
- $rResult = APIRequest(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
+ $rResult = ApiClient::request(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
}
echo json_encode(array('result' => true));
@@ -1107,7 +1107,7 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rStreamIDs)) {
} else {
- $rResult = APIRequest(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
+ $rResult = ApiClient::request(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
}
echo json_encode(array('result' => true));
@@ -1128,7 +1128,7 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rStreamIDs)) {
} else {
- $rResult = APIRequest(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
+ $rResult = ApiClient::request(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => array_values($rStreamIDs), 'servers' => array(intval(RequestManager::getAll()['server_id']))));
}
echo json_encode(array('result' => true));
@@ -1239,7 +1239,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- removeAccessEntry(RequestManager::getAll()['code_id']);
+ AuthRepository::deleteCode(RequestManager::getAll()['code_id']);
echo json_encode(array('result' => true));
exit();
@@ -1259,7 +1259,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- validateHMAC(RequestManager::getAll()['hmac_id']);
+ AuthRepository::deleteHMAC(RequestManager::getAll()['hmac_id']);
echo json_encode(array('result' => true));
exit();
@@ -1306,7 +1306,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteBouquet(RequestManager::getAll()['bouquet_id']);
+ BouquetService::deleteById(RequestManager::getAll()['bouquet_id']);
echo json_encode(array('result' => true));
exit();
@@ -1326,7 +1326,7 @@ if (isset($_SESSION['hash'])) {
$rSub = RequestManager::getAll()['sub'];
if ($rSub == 'delete') {
- deleteCategory(RequestManager::getAll()['category_id']);
+ CategoryService::deleteById(RequestManager::getAll()['category_id']);
echo json_encode(array('result' => true));
exit();
@@ -1410,7 +1410,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'graph_stats') {
$rLimit = 3600;
- $rTime = roundUpToAny(time(), 10);
+ $rTime = AdminHelpers::roundUpToAny(time(), 10);
$rNearestRange = $rTime - $rLimit;
$rPeriod = 60;
$rStatsRange = array();
@@ -1431,7 +1431,7 @@ if (isset($_SESSION['hash'])) {
foreach ($db->get_rows() as $rRow) {
if (!$rServers[$rRow['server_id']]['server_online']) {
} else {
- $rNearest = getNearest($rStatsRange, intval($rRow['time']));
+ $rNearest = AdminHelpers::getNearest($rStatsRange, intval($rRow['time']));
if (isset($rStatsRange[$rNearest][intval($rRow['server_id'])])) {
} else {
@@ -2158,7 +2158,7 @@ if (isset($_SESSION['hash'])) {
if (0 >= strlen($rTerm)) {
} else {
- include MAIN_HOME . 'includes/libs/tmdb.php';
+ include MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
if (0 < strlen(RequestManager::getAll()['language'])) {
$rTMDB = new TMDB($rSettings['tmdb_api_key'], RequestManager::getAll()['language']);
@@ -2192,7 +2192,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rRelease = parserelease($rTerm);
+ $rRelease = AdminHelpers::parserelease($rTerm);
$rTerm = $rRelease['title'];
$rJSON = array();
@@ -2231,7 +2231,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'tmdb') {
if (Authorization::check('adv', 'add_series') || Authorization::check('adv', 'edit_series') || Authorization::check('adv', 'add_movie') || Authorization::check('adv', 'edit_movie') || Authorization::check('adv', 'add_episode') || Authorization::check('adv', 'edit_episode')) {
- include MAIN_HOME . 'includes/libs/tmdb.php';
+ include MAIN_HOME . 'modules/tmdb/lib/TmdbClient.php';
if (0 < strlen(RequestManager::getAll()['language'])) {
$rTMDB = new TMDB($rSettings['tmdb_api_key'], RequestManager::getAll()['language']);
@@ -2254,7 +2254,7 @@ if (isset($_SESSION['hash'])) {
} else {
$rSeries = $rTMDB->getTVShow($rID);
$rResult = json_decode($rSeries->getJSON(), true);
- $rResult['trailer'] = getSeriesTrailer($rID, (!empty(RequestManager::getAll()['language']) ? RequestManager::getAll()['language'] : $rSettings['tmdb_language']));
+ $rResult['trailer'] = TMDbService::getSeriesTrailer($rID, (!empty(RequestManager::getAll()['language']) ? RequestManager::getAll()['language'] : $rSettings['tmdb_language']));
}
}
@@ -2291,7 +2291,7 @@ if (isset($_SESSION['hash'])) {
exit();
}
- echo json_encode(array('result' => true, 'data' => listDir(intval(RequestManager::getAll()['server']), RequestManager::getAll()['dir'], $rFilter)));
+ echo json_encode(array('result' => true, 'data' => ApiClient::listDir(intval(RequestManager::getAll()['server']), RequestManager::getAll()['dir'], $rFilter)));
exit();
}
@@ -2372,7 +2372,7 @@ if (isset($_SESSION['hash'])) {
}
$rArray['action'] = 'signal_send';
- $rSuccess = systemapirequest(intval($rRow['server_id']), $rArray);
+ $rSuccess = ApiClient::systemRequest(intval($rRow['server_id']), $rArray);
}
}
}
@@ -2715,15 +2715,15 @@ if (isset($_SESSION['hash'])) {
}
if ($rStartTime && $rEndTime) {
- $db->query('DELETE FROM ' . preparecolumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` >= ? AND `' . $rColumn . '` <= ?;', $rStartTime, $rEndTime);
+ $db->query('DELETE FROM ' . QueryHelper::prepareColumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` >= ? AND `' . $rColumn . '` <= ?;', $rStartTime, $rEndTime);
} else {
if ($rStartTime) {
- $db->query('DELETE FROM ' . preparecolumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` >= ?;', $rStartTime);
+ $db->query('DELETE FROM ' . QueryHelper::prepareColumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` >= ?;', $rStartTime);
} else {
if ($rEndTime) {
- $db->query('DELETE FROM ' . preparecolumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` <= ?;', $rEndTime);
+ $db->query('DELETE FROM ' . QueryHelper::prepareColumn(RequestManager::getAll()['type']) . ' WHERE `' . $rColumn . '` <= ?;', $rEndTime);
} else {
- $db->query('TRUNCATE ' . preparecolumn(RequestManager::getAll()['type']) . ';');
+ $db->query('TRUNCATE ' . QueryHelper::prepareColumn(RequestManager::getAll()['type']) . ';');
}
}
}
@@ -2769,7 +2769,7 @@ if (isset($_SESSION['hash'])) {
if (0 >= strlen($rSettings['dropbox_token'])) {
} else {
- deleteRemoteBackup('/' . $rBackup . '.sql');
+ BackupService::deleteRemote('/' . $rBackup . '.sql');
}
echo json_encode(array('result' => true));
@@ -2786,7 +2786,7 @@ if (isset($_SESSION['hash'])) {
$rFilename = MAIN_HOME . 'tmp/restore.sql';
if (0 < strlen($rSettings['dropbox_token'])) {
- if (downloadRemoteBackup('/' . $rBackup . '.sql', $rFilename)) {
+ if (BackupService::downloadRemote('/' . $rBackup . '.sql', $rFilename)) {
} else {
echo json_encode(array('result' => false));
@@ -2842,7 +2842,7 @@ if (isset($_SESSION['hash'])) {
$rData['message'] = intval($rData['channel']);
} else {
if ($rData['type'] == 'reset_stb_lock') {
- resetSTB($rData['id']);
+ MagService::resetSTB($rData['id']);
} else {
$rData['need_confirm'] = 0;
$rData['reboot_portal'] = 0;
@@ -3021,7 +3021,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'rtmp_kill') {
if (Authorization::check('adv', 'rtmp')) {
- echo systemapirequest(intval(RequestManager::getAll()['server']), array('action' => 'rtmp_kill', 'name' => RequestManager::getAll()['name']));
+ echo ApiClient::systemRequest(intval(RequestManager::getAll()['server']), array('action' => 'rtmp_kill', 'name' => RequestManager::getAll()['name']));
exit();
}
@@ -3090,7 +3090,7 @@ if (isset($_SESSION['hash'])) {
}
if (RequestManager::getAll()['action'] == 'fpm_status') {
if (Authorization::check('adv', 'add_server') || Authorization::check('adv', 'edit_server')) {
- $rData = str_replace("\n", '
', systemapirequest(RequestManager::getAll()['server_id'], array('action' => 'fpm_status')));
+ $rData = str_replace("\n", '
', ApiClient::systemRequest(RequestManager::getAll()['server_id'], array('action' => 'fpm_status')));
if (empty($rData)) {
$rData = 'No response from status page.';
@@ -3327,13 +3327,13 @@ if (isset($_SESSION['hash'])) {
$rParams['report'] = true;
$rParams['start'] = 0;
$rParams['length'] = 100000;
- $rData = json_decode(generateReport($rURL, $rParams), true);
+ $rData = json_decode(AdminHelpers::generateReport($rURL, $rParams), true);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=report_' . preg_replace('/[^A-Za-z0-9 ]/', '', $rParams['id']) . '_' . date('YmdHis') . '.csv');
if (0 >= count(($rData['data'] ?: array()))) {
} else {
- echo file_get_contents(convertToCSV($rData['data']));
+ echo file_get_contents(AdminHelpers::convertToCSV($rData['data']));
}
exit();
@@ -3415,7 +3415,7 @@ if (isset($_SESSION['hash'])) {
foreach ($rData as $rEpisodeID => $rName) {
$rInput[$rEpisodeID] = pathinfo(str_replace('-', '_', $rName))['filename'];
}
- $rCommand = '/usr/bin/python3 ' . MAIN_HOME . 'includes/python/release.py ' . escapeshellarg(json_encode($rInput));
+ $rCommand = '/usr/bin/python3 ' . MAIN_HOME . 'bin/python/release.py ' . escapeshellarg(json_encode($rInput));
}
$rEpisodes = json_decode(shell_exec($rCommand), true);
@@ -3730,7 +3730,7 @@ if (isset($_SESSION['hash'])) {
}
}
$rDeviceLines = $rStreamNames = $rLinesInfo = $rOwnerNames = $rUsersCount = $rLinesCount = $rSeriesInfo = $rSeriesTitles = $rServerItems = $rServerCount = $rConnectionCount = $rLineConnectionCount = array();
- $rDeviceIDs = confirmIDs($rDeviceIDs);
+ $rDeviceIDs = AdminHelpers::confirmIDs($rDeviceIDs);
if (0 >= count($rDeviceIDs)) {
} else {
@@ -3746,7 +3746,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rStreamIDs = confirmIDs($rStreamIDs);
+ $rStreamIDs = AdminHelpers::confirmIDs($rStreamIDs);
if (0 >= count($rStreamIDs)) {
} else {
@@ -3784,7 +3784,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rSeriesIDs = confirmIDs($rSeriesIDs);
+ $rSeriesIDs = AdminHelpers::confirmIDs($rSeriesIDs);
if (0 >= count($rSeriesIDs)) {
} else {
@@ -3795,7 +3795,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rUserIDs = confirmIDs($rUserIDs);
+ $rUserIDs = AdminHelpers::confirmIDs($rUserIDs);
if (0 >= count($rUserIDs)) {
} else {
@@ -3811,7 +3811,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rOwnerIDs = confirmIDs($rOwnerIDs);
+ $rOwnerIDs = AdminHelpers::confirmIDs($rOwnerIDs);
if (0 >= count($rOwnerIDs)) {
} else {
@@ -3822,7 +3822,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rLineIDs = confirmIDs($rLineIDs);
+ $rLineIDs = AdminHelpers::confirmIDs($rLineIDs);
if (0 >= count($rLineIDs)) {
} else {
@@ -3872,7 +3872,7 @@ if (isset($_SESSION['hash'])) {
}
}
- $rStreamNameIDs = confirmIDs($rStreamNameIDs);
+ $rStreamNameIDs = AdminHelpers::confirmIDs($rStreamNameIDs);
if (0 >= count($rStreamNameIDs)) {
} else {
@@ -4594,9 +4594,9 @@ if (isset($_SESSION['hash'])) {
} else {
if ($rSub == 'delete') {
if ($rType == 'mag') {
- deleteMAGs($rRequestIDs);
+ MagService::deleteDevices($rRequestIDs);
} else {
- deleteEnigmas($rRequestIDs);
+ EnigmaService::deleteDevices($rRequestIDs);
}
} else {
if ($rSub == 'enable') {
@@ -4630,9 +4630,9 @@ if (isset($_SESSION['hash'])) {
} else {
foreach ($rRequestIDs as $rDeviceID) {
if ($rType == 'mag') {
- deleteMAG($rDeviceID, false, false, true);
+ MagService::deleteDevice($rDeviceID, false, false, true);
} else {
- deleteEnigma($rDeviceID, false, false, true);
+ EnigmaService::deleteDevice($rDeviceID, false, false, true);
}
}
}
@@ -4666,7 +4666,7 @@ if (isset($_SESSION['hash'])) {
} else {
if ($rSub != 'delete') {
} else {
- deleteUsers($rRequestIDs);
+ UserService::deleteRegisteredUsers($rRequestIDs);
}
}
}
@@ -4703,9 +4703,9 @@ if (isset($_SESSION['hash'])) {
} else {
foreach ($rStreamMap as $rServerID => $rStreamIDs) {
if ($rSub == 'stop') {
- APIRequest(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
+ ApiClient::request(array('action' => 'stream', 'sub' => 'stop', 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
} else {
- APIRequest(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
+ ApiClient::request(array('action' => 'stream', 'sub' => 'start', 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
}
}
}
@@ -4776,7 +4776,7 @@ if (isset($_SESSION['hash'])) {
case 'series':
if ($rSub != 'delete') {
} else {
- deleteSeriesMass($rRequestIDs);
+ SeriesService::deleteSeriesByIds($rRequestIDs);
}
echo json_encode(array('result' => true));
@@ -4833,9 +4833,9 @@ if (isset($_SESSION['hash'])) {
foreach ($rStreamMap as $rServerID => $rStreamIDs) {
if (in_array($rType, array('stream', 'radio', 'cchannel'))) {
- APIRequest(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
+ ApiClient::request(array('action' => 'stream', 'sub' => $rSub, 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
} else {
- APIRequest(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
+ ApiClient::request(array('action' => 'vod', 'sub' => $rSub, 'stream_ids' => $rStreamIDs, 'servers' => array($rServerID)));
}
}
} else {
@@ -4843,13 +4843,13 @@ if (isset($_SESSION['hash'])) {
if (0 >= count($rStreamMap)) {
} else {
foreach ($rStreamMap as $rServerID => $rStreamIDs) {
- deleteStreamsByServer($rStreamIDs, $rServerID, $rDeleteFiles = true);
+ StreamRepository::deleteStreamsByServer($rStreamIDs, $rServerID, $rDeleteFiles = true);
}
}
if (0 >= count($rUnallocated)) {
} else {
- deleteStreams($rUnallocated, true);
+ StreamRepository::deleteStreams($rUnallocated, true);
}
} else {
if ($rSub != 'purge') {
diff --git a/src/public/Views/admin/archive.php b/src/public/Views/admin/archive.php
index 2e01118e..1ef18ce0 100644
--- a/src/public/Views/admin/archive.php
+++ b/src/public/Views/admin/archive.php
@@ -4,8 +4,8 @@
include 'session.php';
include 'functions.php';
- if (!checkPermissions()) {
- goHome();
+ if (!PageAuthorization::checkPermissions()) {
+ AdminHelpers::goHome();
}
$rRecordings = null;
@@ -14,10 +14,10 @@
$rStream = StreamRepository::getById(RequestManager::getAll()['id']);
if (!$rStream || $rStream['type'] != 1 || $rStream['tv_archive_duration'] == 0 || $rStream['tv_archive_server_id'] == 0) {
- goHome();
+ AdminHelpers::goHome();
}
- $rArchive = getArchive($rStream['id']);
+ $rArchive = StreamService::getArchive($rStream['id']);
} else {
$rRecordings = WatchService::getRecordings();
}
diff --git a/src/public/Views/admin/asns.php b/src/public/Views/admin/asns.php
index f401b1c9..e404c70b 100644
--- a/src/public/Views/admin/asns.php
+++ b/src/public/Views/admin/asns.php
@@ -4,8 +4,8 @@
include 'session.php';
include 'functions.php';
- if (!checkPermissions()) {
- goHome();
+ if (!PageAuthorization::checkPermissions()) {
+ AdminHelpers::goHome();
}
$_TITLE = "ASN's";
diff --git a/src/public/Views/admin/backups.php b/src/public/Views/admin/backups.php
index e144a9aa..c6fca5ba 100644
--- a/src/public/Views/admin/backups.php
+++ b/src/public/Views/admin/backups.php
@@ -4,8 +4,8 @@
include 'session.php';
include 'functions.php';
- if (!checkPermissions()) {
- goHome();
+ if (!PageAuthorization::checkPermissions()) {
+ AdminHelpers::goHome();
}
$_TITLE = 'Backups';
@@ -90,7 +90,7 @@