Files
easystream/f_modules/m_frontend/m_cron/chat-server/sync_subs.php
T
SamiAhmed7777 0b7e2d0a5b feat: Add comprehensive documentation suite and reorganize project structure
- Created complete documentation in docs/ directory
- Added PROJECT_OVERVIEW.md with feature highlights and getting started guide
- Added ARCHITECTURE.md with system design and technical details
- Added SECURITY.md with comprehensive security implementation guide
- Added DEVELOPMENT.md with development workflows and best practices
- Added DEPLOYMENT.md with production deployment instructions
- Added API.md with complete REST API documentation
- Added CONTRIBUTING.md with contribution guidelines
- Added CHANGELOG.md with version history and migration notes
- Reorganized all documentation files into docs/ directory for better organization
- Updated README.md with proper documentation links and quick navigation
- Enhanced project structure with professional documentation standards
2025-10-21 00:39:45 -07:00

103 lines
3.7 KiB
PHP

<?php
/*******************************************************************************************************************
| Software Name : EasyStream
| Software Description : High End YouTube Clone Script with Videos, Shorts, Streams, Images, Audio, Documents, Blogs
| Software Author : (c) Sami Ahmed
|*******************************************************************************************************************
|
|*******************************************************************************************************************
| This source file is subject to the EasyStream Proprietary License Agreement.
|
| By using this software, you acknowledge having read this Agreement and agree to be bound thereby.
|*******************************************************************************************************************
| Copyright (c) 2025 Sami Ahmed. All rights reserved.
|*******************************************************************************************************************/
ini_set("error_reporting", E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
define('_ISVALID', true);
require 'cfg.php';
$url = $base . '/syncsubs?s=';
$date = date("Y-m-d");
$tk = md5($date . $ssk);
$url .= $tk;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($curl);
curl_close($curl);
$list = json_decode($data);
/* follows */
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if (!$conn) {
die('Could not connect: ' . mysqli_error());
}
echo "Connected successfully\n";
if (is_object($list->followers)) {
foreach ($list->followers as $usr_id => $users) {
if ($usr_id > 0) {
$sql = sprintf("SELECT `db_id` FROM `db_livefollows` WHERE `channel_id`='%s' LIMIT 1;", $usr_id);
$r = mysqli_query($conn, $sql);
$n = $r->num_rows;
$v = $r->fetch_assoc();
if ($n > 0) {
$sql = sprintf("UPDATE `db_livefollows` SET `follow_list`='%s' WHERE `db_id`='%s' LIMIT 1;", json_encode($users), $v["db_id"]);
} else {
$sql = sprintf("INSERT INTO `db_livefollows` (`channel_id`, `follow_list`) VALUES ('%s', '%s');", $usr_id, json_encode($users));
}
if (mysqli_query($conn, $sql)) {
echo "db_livefollows records updated successfully for channel_id $usr_id\n";
} else {
echo "Error updating record: " . mysqli_error($conn) . "\n";
}
}
}
}
mysqli_close($conn);
/* subs */
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if (!$conn) {
die('Could not connect: ' . mysqli_error());
}
echo "Connected successfully\n";
if (is_object($list->subscribers)) {
foreach ($list->subscribers as $usr_id => $users) {
if ($usr_id > 0) {
$sql = sprintf("SELECT `db_id` FROM `db_livesubs` WHERE `channel_id`='%s' LIMIT 1;", $usr_id);
$r = mysqli_query($conn, $sql);
$n = $r->num_rows;
$v = $r->fetch_assoc();
if ($n > 0) {
$sql = sprintf("UPDATE `db_livesubs` SET `sub_list`='%s' WHERE `db_id`='%s' LIMIT 1;", json_encode($users), $v["db_id"]);
} else {
$sql = sprintf("INSERT INTO `db_livesubs` (`channel_id`, `sub_list`) VALUES ('%s', '%s');", $usr_id, json_encode($users));
}
if (mysqli_query($conn, $sql)) {
echo "db_livesubs records updated successfully for channel_id $usr_id\n";
} else {
echo "Error updating record: " . mysqli_error($conn) . "\n";
}
}
}
}
mysqli_close($conn);