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
This commit is contained in:
14
f_modules/m_frontend/m_cron/chat-server/cfg.php
Normal file
14
f_modules/m_frontend/m_cron/chat-server/cfg.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
ini_set("error_reporting", E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
|
||||
|
||||
define('_ISVALID', true);
|
||||
|
||||
/* database */
|
||||
$dbhost = getenv('DB_HOST') ?: 'db';
|
||||
$dbname = getenv('DB_NAME') ?: 'easystream';
|
||||
$dbuser = getenv('DB_USER') ?: 'easystream';
|
||||
$dbpass = getenv('DB_PASS') ?: 'easystream';
|
||||
/* main url */
|
||||
$base = getenv('CRON_BASE_URL') ?: 'http://localhost:8080';
|
||||
/* cron salt key */
|
||||
$ssk = getenv('CRON_SSK') ?: 'CHANGE_ME_IN_BACKEND';
|
||||
139
f_modules/m_frontend/m_cron/chat-server/chat.php
Normal file
139
f_modules/m_frontend/m_cron/chat-server/chat.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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);
|
||||
|
||||
$main_dir = realpath(dirname(__FILE__) . '/../../../../');
|
||||
set_include_path($main_dir);
|
||||
|
||||
include_once 'filter.php';
|
||||
|
||||
$class_filter = new VFilter;
|
||||
|
||||
$host = array('127.0.0.1');
|
||||
|
||||
$_POST = $HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
||||
//$_POST = $HTTP_RAW_POST_DATA;
|
||||
$post = json_decode($_POST);
|
||||
|
||||
if ($_POST and in_array($_SERVER["REMOTE_ADDR"], $host)) {
|
||||
require 'cfg.php';
|
||||
|
||||
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die('Could not connect: ' . mysqli_error());
|
||||
}
|
||||
echo "Connected successfully\n";
|
||||
|
||||
$salt = $cfg["live_chat_salt"];
|
||||
$p_chatid = $class_filter->clr_str($post->a);
|
||||
$p_fkey = $class_filter->clr_str($post->b);
|
||||
$p_nick = $class_filter->clr_str($post->c);
|
||||
$p_dnick = $class_filter->clr_str($post->cd);
|
||||
$p_ip = $class_filter->clr_str($post->d);
|
||||
$p_chid = $class_filter->clr_str($post->e);
|
||||
$p_uid = $class_filter->clr_str($post->f);
|
||||
$p_cua = $class_filter->clr_str($post->g);
|
||||
$p_own = $class_filter->clr_str($post->h);
|
||||
$p_ukey = $class_filter->clr_str($post->i);
|
||||
$p_badge = $class_filter->clr_str($post->j);
|
||||
$p_live = (int) $post->k;
|
||||
$p_first = (int) $post->first;
|
||||
$p_inc = (int) $post->inc;
|
||||
$cip = $p_ip;
|
||||
$p_fp = $p_cua;
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livechat` WHERE `channel_id`='%s' AND `chat_id`='%s' AND `stream_id`='%s' LIMIT 1;", $p_chid, $p_chatid, $p_fkey);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
$v = $r->fetch_assoc();
|
||||
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livechat` (`first`, `chat_id`, `channel_id`, `channel_owner`, `usr_id`, `usr_key`, `stream_id`, `chat_user`, `chat_display`, `is_live`, `chat_ip`, `chat_fp`, `chat_time`, `badge`, `logged_in`, `usr_profileinc`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');",
|
||||
$p_first, $p_chatid, $p_chid, $p_own, $p_uid, $p_ukey, $p_fkey, $p_nick, $p_dnick, $p_live, $p_ip, $p_fp, date("Y-m-d H:i:s"), $p_badge, (substr($p_nick, 0, 5) === "Guest" ? 0 : 1), $p_inc);
|
||||
$r = mysqli_query($conn, $q);
|
||||
} else {
|
||||
$q = sprintf("UPDATE `db_livechat` SET `is_live`='%s', `chat_display`='%s', `usr_profileinc`='%s', `first`='%s', `chat_ip`='%s', `chat_fp`='%s' WHERE `db_id`='%s' LIMIT 1;", $p_live, $p_dnick, $p_inc, $p_first, $p_ip, $p_fp, $v["db_id"]);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livemods` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livemods` (`channel_id`, `mod_list`) VALUES ('%s', '[]');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livevips` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livevips` (`channel_id`, `vip_list`) VALUES ('%s', '[]');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livebans` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livebans` (`channel_id`, `ban_list`) VALUES ('%s', '[]');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livefollows` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livefollows` (`channel_id`, `follow_list`) VALUES ('%s', '[]');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livesubs` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livesubs` (`channel_id`, `sub_list`) VALUES ('%s', '[]');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_livesettings` WHERE `channel_id`='%s' LIMIT 1;", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livesettings` (`channel_id`) VALUES ('%s');", $p_chid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `db_id` FROM `db_liveignore` WHERE `usr_id`='%s' LIMIT 1;", $p_uid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_liveignore` (`usr_id`, `ignore_list`) VALUES ('%s', '[]');", $p_uid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
$q = sprintf("SELECT `color_class`, `color_code`, `timestamps`, `modicons` FROM `db_livecolors` WHERE `usr_id`='%s' LIMIT 1", $p_uid);
|
||||
$r = mysqli_query($conn, $q);
|
||||
$rn = $r->num_rows;
|
||||
if ($rn == 0) {
|
||||
$q = sprintf("INSERT INTO `db_livecolors` (`usr_id`, `color_class`, `modicons`, `timestamps`) VALUES ('%s', '%s', '0', '0');", $p_uid, 'c' . rand(1, 15));
|
||||
$r = mysqli_query($conn, $q);
|
||||
}
|
||||
|
||||
mysqli_close($conn);
|
||||
}
|
||||
44
f_modules/m_frontend/m_cron/chat-server/clean_chat.php
Normal file
44
f_modules/m_frontend/m_cron/chat-server/clean_chat.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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';
|
||||
|
||||
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die('Could not connect: ' . mysqli_error());
|
||||
}
|
||||
echo "Connected successfully\n";
|
||||
|
||||
$sql = sprintf("DELETE FROM `db_livenotifications` WHERE `displayed`='1';");
|
||||
|
||||
if (mysqli_query($conn, $sql)) {
|
||||
echo "db_livenotifications updated successfully\n";
|
||||
} else {
|
||||
echo "Error updating table db_livenotifications: " . mysqli_error($conn) . "\n";
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `db_livechat` WHERE `chat_user` LIKE 'Guest%';";
|
||||
|
||||
if (mysqli_query($conn, $sql)) {
|
||||
echo "db_livechat records updated successfully\n";
|
||||
} else {
|
||||
echo "Error updating db_livechat: " . mysqli_error($conn) . "\n";
|
||||
}
|
||||
|
||||
mysqli_close($conn);
|
||||
341
f_modules/m_frontend/m_cron/chat-server/filter.php
Normal file
341
f_modules/m_frontend/m_cron/chat-server/filter.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?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);
|
||||
|
||||
defined('_ISVALID') or header('Location: /error');
|
||||
/**
|
||||
* Sanitize HTML body content
|
||||
* Remove dangerous tags and attributes that can lead to security issues like
|
||||
* XSS or HTTP response splitting
|
||||
*/
|
||||
class VFilter
|
||||
{
|
||||
// Private fields
|
||||
public $_encoding;
|
||||
public $_allowedTags;
|
||||
public $_allowJavascriptEvents;
|
||||
public $_allowJavascriptInUrls;
|
||||
public $_allowObjects;
|
||||
public $_allowScript;
|
||||
public $_allowStyle;
|
||||
public $_additionalTags;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function HTML_Sanitizer()
|
||||
{
|
||||
$this->resetAll();
|
||||
}
|
||||
/**
|
||||
* (re)set all options to default value
|
||||
*/
|
||||
public function resetAll()
|
||||
{
|
||||
$this->_encoding = 'UTF-8';
|
||||
$this->_allowDOMEvents = false;
|
||||
$this->_allowJavascriptInUrls = false;
|
||||
$this->_allowStyle = false;
|
||||
$this->_allowScript = false;
|
||||
$this->_allowObjects = false;
|
||||
$this->_allowStyle = false;
|
||||
|
||||
$this->_allowedTags = '<a><br><b><h1><h2><h3><h4><h5><h6>'
|
||||
. '<img><li><ol><p><strong><table><tr><td><th><u><ul><thead>'
|
||||
. '<tbody><tfoot><em><dd><dt><dl><span><div><del><add><i><hr>'
|
||||
. '<pre><br><blockquote><address><code><caption><abbr><acronym>'
|
||||
. '<cite><dfn><q><ins><sup><sub><kbd><samp><var><tt><small><big>'
|
||||
;
|
||||
$this->_additionalTags = '';
|
||||
}
|
||||
/**
|
||||
* Add additional tags to allowed tags
|
||||
* @param string
|
||||
* @access public
|
||||
*/
|
||||
public function addAdditionalTags($tags)
|
||||
{$this->_additionalTags .= $tags;}
|
||||
/**
|
||||
* Allow object, embed, applet and param tags in html
|
||||
* @access public
|
||||
*/
|
||||
public function allowObjects()
|
||||
{$this->_allowObjects = true;}
|
||||
/**
|
||||
* Allow DOM event on DOM elements
|
||||
* @access public
|
||||
*/
|
||||
public function allowDOMEvents()
|
||||
{$this->_allowDOMEvents = true;}
|
||||
/**
|
||||
* Allow script tags
|
||||
* @access public
|
||||
*/
|
||||
public function allowScript()
|
||||
{$this->_allowScript = true;}
|
||||
/**
|
||||
* Allow the use of javascript: in urls
|
||||
* @access public
|
||||
*/
|
||||
public function allowJavascriptInUrls()
|
||||
{$this->_allowJavascriptInUrls = true;}
|
||||
/**
|
||||
* Allow style tags and attributes
|
||||
* @access public
|
||||
*/
|
||||
public function allowStyle()
|
||||
{$this->_allowStyle = true;}
|
||||
/**
|
||||
* Helper to allow all javascript related tags and attributes
|
||||
* @access public
|
||||
*/
|
||||
public function allowAllJavascript()
|
||||
{
|
||||
$this->allowDOMEvents();
|
||||
$this->allowScript();
|
||||
$this->allowJavascriptInUrls();
|
||||
}
|
||||
/**
|
||||
* Allow all tags and attributes
|
||||
* @access public
|
||||
*/
|
||||
public function allowAll()
|
||||
{
|
||||
$this->allowAllJavascript();
|
||||
$this->allowObjects();
|
||||
$this->allowStyle();
|
||||
}
|
||||
/**
|
||||
* Filter URLs to avoid HTTP response splitting attacks
|
||||
* @access public
|
||||
* @param string url
|
||||
* @return string filtered url
|
||||
*/
|
||||
public function filterHTTPResponseSplitting($url)
|
||||
{
|
||||
$dangerousCharactersPattern = '~(\r\n|\r|\n|%0a|%0d|%0D|%0A)~';
|
||||
return preg_replace($dangerousCharactersPattern, '', $url);
|
||||
}
|
||||
/**
|
||||
* Remove potential javascript in urls
|
||||
* @access public
|
||||
* @param string url
|
||||
* @return string filtered url
|
||||
*/
|
||||
public function removeJavascriptURL($str)
|
||||
{
|
||||
$HTML_Sanitizer_stripJavascriptURL = 'javascript:[^"]+';
|
||||
|
||||
$str = preg_replace("/$HTML_Sanitizer_stripJavascriptURL/i"
|
||||
, ''
|
||||
, $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* Remove potential flaws in urls
|
||||
* @access private
|
||||
* @param string url
|
||||
* @return string filtered url
|
||||
*/
|
||||
public function sanitizeURL($url)
|
||||
{
|
||||
if (!$this->_allowJavascriptInUrls) {$url = $this->removeJavascriptURL($url);}
|
||||
$url = $this->filterHTTPResponseSplitting($url);
|
||||
|
||||
return $url;
|
||||
}
|
||||
/**
|
||||
* Callback for PCRE
|
||||
* @access private
|
||||
* @param matches array
|
||||
* @return string
|
||||
* @see sanitizeURL
|
||||
*/
|
||||
public function _sanitizeURLCallback($matches)
|
||||
{return 'href="' . $this->sanitizeURL($matches[1]) . '"';}
|
||||
/**
|
||||
* Remove potential flaws in href attributes
|
||||
* @access private
|
||||
* @param string html tag
|
||||
* @return string filtered html tag
|
||||
*/
|
||||
public function sanitizeHref($str)
|
||||
{
|
||||
$HTML_Sanitizer_URL = 'href="([^"]+)"';
|
||||
|
||||
return preg_replace_callback("/$HTML_Sanitizer_URL/i"
|
||||
, array(&$this, '_sanitizeURLCallback')
|
||||
, $str);
|
||||
}
|
||||
/**
|
||||
* Callback for PCRE
|
||||
* @access private
|
||||
* @param matches array
|
||||
* @return string
|
||||
* @see sanitizeURL
|
||||
*/
|
||||
public function _sanitizeSrcCallback($matches)
|
||||
{return 'src="' . $this->sanitizeURL($matches[1]) . '"';}
|
||||
/**
|
||||
* Remove potential flaws in href attributes
|
||||
* @access private
|
||||
* @param string html tag
|
||||
* @return string filtered html tag
|
||||
*/
|
||||
public function sanitizeSrc($str)
|
||||
{
|
||||
$HTML_Sanitizer_URL = 'src="([^"]+)"';
|
||||
|
||||
return preg_replace_callback("/$HTML_Sanitizer_URL/i"
|
||||
, array(&$this, '_sanitizeSrcCallback')
|
||||
, $str);
|
||||
}
|
||||
/**
|
||||
* Remove dangerous attributes from html tags
|
||||
* @access private
|
||||
* @param string html tag
|
||||
* @return string filtered html tag
|
||||
*/
|
||||
public function removeEvilAttributes($str)
|
||||
{
|
||||
if (!$this->_allowDOMEvents) {
|
||||
$str = preg_replace_callback('/<(.*?)>/i'
|
||||
, array(&$this, '_removeDOMEventsCallback')
|
||||
, $str);
|
||||
}
|
||||
if (!$this->_allowStyle) {
|
||||
$str = preg_replace_callback('/<(.*?)>/i'
|
||||
, array(&$this, '_removeStyleCallback')
|
||||
, $str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* Remove DOM events attributes from html tags
|
||||
* @access private
|
||||
* @param string html tag
|
||||
* @return string filtered html tag
|
||||
*/
|
||||
public function removeDOMEvents($str)
|
||||
{
|
||||
$str = preg_replace('/\s*=\s*/', '=', $str);
|
||||
|
||||
$HTML_Sanitizer_stripAttrib = '(onclick|ondblclick|onmousedown|'
|
||||
. 'onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|'
|
||||
. 'onkeyup|onfocus|onblur|onabort|onerror|onload)'
|
||||
;
|
||||
|
||||
$str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i"
|
||||
, 'forbidden'
|
||||
, $str));
|
||||
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* Callback for PCRE
|
||||
* @access private
|
||||
* @param matches array
|
||||
* @return string
|
||||
* @see removeDOMEvents
|
||||
*/
|
||||
public function _removeDOMEventsCallback($matches)
|
||||
{return '<' . $this->removeDOMEvents($matches[1]) . '>';}
|
||||
/**
|
||||
* Remove style attributes from html tags
|
||||
* @access private
|
||||
* @param string html tag
|
||||
* @return string filtered html tag
|
||||
*/
|
||||
public function removeStyle($str)
|
||||
{
|
||||
$str = preg_replace('/\s*=\s*/', '=', $str);
|
||||
|
||||
$HTML_Sanitizer_stripAttrib = '(style)'
|
||||
;
|
||||
|
||||
$str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i"
|
||||
, 'forbidden'
|
||||
, $str));
|
||||
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* Callback for PCRE
|
||||
* @access private
|
||||
* @param matches array
|
||||
* @return string
|
||||
* @see removeStyle
|
||||
*/
|
||||
public function _removeStyleCallback($matches)
|
||||
{return '<' . $this->removeStyle($matches[1]) . '>';}
|
||||
/**
|
||||
* Remove dangerous HTML tags
|
||||
* @access private
|
||||
* @param string html code
|
||||
* @return string filtered url
|
||||
*/
|
||||
public function removeEvilTags($str)
|
||||
{
|
||||
$allowedTags = $this->_allowedTags;
|
||||
|
||||
if ($this->_allowScript) {$allowedTags .= '<script>';}
|
||||
if ($this->_allowStyle) {$allowedTags .= '<style>';}
|
||||
if ($this->_allowObjects) {$allowedTags .= '<object><embed><applet><param>';}
|
||||
|
||||
$allowedTags .= $this->_additionalTags;
|
||||
$str = strip_tags($str, $allowedTags);
|
||||
|
||||
return $str;
|
||||
}
|
||||
public function removeSQLTags($str)
|
||||
{
|
||||
$str = str_ireplace(array('CONCAT', 'ELT(', 'INFORMATION_SCHEMA'), array('', '', ''), $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* Sanitize HTML
|
||||
* remove dangerous tags and attributes
|
||||
* clean urls
|
||||
* @access public
|
||||
* @param string html code
|
||||
* @return string sanitized html code
|
||||
*/
|
||||
public function sanitize($html)
|
||||
{
|
||||
$html = $this->removeEvilTags($html);
|
||||
$html = $this->removeEvilAttributes($html);
|
||||
$html = $this->sanitizeHref($html);
|
||||
$html = $this->sanitizeSrc($html);
|
||||
$html = $this->removeSQLTags($html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function clr_str($str)
|
||||
{
|
||||
static $san = null;
|
||||
if (empty($san)) {$san = new VFilter;}
|
||||
|
||||
return htmlspecialchars($san->sanitize($str), ENT_QUOTES, $this->_encoding);
|
||||
}
|
||||
}
|
||||
|
||||
function html_sanitize($str)
|
||||
{
|
||||
static $san = null;
|
||||
if (empty($san)) {$san = new VFilter;}
|
||||
return $san->sanitize($str);
|
||||
}
|
||||
0
f_modules/m_frontend/m_cron/chat-server/index.html
Normal file
0
f_modules/m_frontend/m_cron/chat-server/index.html
Normal file
0
f_modules/m_frontend/m_cron/chat-server/index.php
Normal file
0
f_modules/m_frontend/m_cron/chat-server/index.php
Normal file
99
f_modules/m_frontend/m_cron/chat-server/notify.php
Normal file
99
f_modules/m_frontend/m_cron/chat-server/notify.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?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);
|
||||
|
||||
$main_dir = realpath(dirname(__FILE__) . '/../../../../');
|
||||
set_include_path($main_dir);
|
||||
|
||||
include_once 'filter.php';
|
||||
|
||||
$class_filter = new VFilter;
|
||||
|
||||
//include_once $class_language->setLanguageFile('frontend', 'language.global');
|
||||
|
||||
$host = array('127.0.0.1');
|
||||
|
||||
$_POST = $HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
||||
|
||||
$post = json_decode($_POST);
|
||||
|
||||
if ($_POST and in_array($_SERVER["REMOTE_ADDR"], $host)) {
|
||||
require 'cfg.php';
|
||||
|
||||
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die('Could not connect: ' . mysqli_error($conn));
|
||||
}
|
||||
echo "Connected successfully\n";
|
||||
|
||||
$cid = $class_filter->clr_str($post->a);
|
||||
$sid = $class_filter->clr_str($post->e);
|
||||
$type = is_array($post->b) ? $post->b : $class_filter->clr_str($post->b);
|
||||
$user = $class_filter->clr_str($post->c);
|
||||
$user2 = $class_filter->clr_str($post->d);
|
||||
$pk = $class_filter->clr_str($post->g);
|
||||
|
||||
switch ($type) {
|
||||
case "follow":
|
||||
case "unfollow":
|
||||
$text = $type == 'follow' ? $user . ' is now following' : $user . ' has unfollowed';
|
||||
$sql = sprintf("SELECT `db_id`, `chat_user`, `channel_id`, `channel_owner`, `usr_id`, `logged_in` FROM `db_livechat` WHERE `stream_id`='%s' AND `chat_id`='%s' ORDER BY `db_id` DESC LIMIT 1;", $sid, $cid);
|
||||
$r = mysqli_query($conn, $sql);
|
||||
$rn = $r->num_rows;
|
||||
$rv = $r->fetch_assoc();
|
||||
|
||||
if ($rn > 0) {
|
||||
$ch_id = $rv["channel_id"];
|
||||
$sql = sprintf("SELECT `db_id` FROM `db_livenotifications` WHERE `type`='follow' AND `channel_id`='%s' AND `text` LIKE '%s' LIMIT 1;", $ch_id, $user . '%');
|
||||
$rr = mysqli_query($conn, $sql);
|
||||
|
||||
if ($rr->num_rows == 0 and $type == 'follow') {
|
||||
$q = sprintf("INSERT INTO `db_livenotifications` (`type`, `channel_id`, `text`, `displayed`) VALUES ('%s', '%s', '%s', '0');", $type, $ch_id, $text);
|
||||
mysqli_query($conn, $q);
|
||||
}
|
||||
}
|
||||
|
||||
mysqli_close($conn);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (is_array($type) and ($type[0] == 'subscribe' or $type[0] == 'unsubscribe')) {
|
||||
$text = $type[0] == 'subscribe' ? $user2 . ' has subscribed with a ' . $pk . ' subscription' : $user2 . ' has unsubscribed';
|
||||
$sql = sprintf("SELECT `db_id`, `chat_user`, `channel_id`, `channel_owner`, `usr_id`, `logged_in` FROM `db_livechat` WHERE `stream_id`='%s' AND `chat_id`='%s' ORDER BY `db_id` DESC LIMIT 1;", $sid, $cid);
|
||||
$r = mysqli_query($conn, $sql);
|
||||
$rn = $r->num_rows;
|
||||
$rv = $r->fetch_assoc();
|
||||
|
||||
if ($rn > 0) {
|
||||
$ch_id = $rv["channel_id"];
|
||||
|
||||
if ($type[0] == 'subscribe') {
|
||||
$q = sprintf("INSERT INTO `db_livenotifications` (`type`, `channel_id`, `text`, `displayed`) VALUES ('%s', '%s', '%s', '0');", $type[0], $ch_id, $text);
|
||||
mysqli_query($conn, $q);
|
||||
}
|
||||
}
|
||||
}
|
||||
mysqli_close($conn);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($conn) {
|
||||
mysqli_close($conn);
|
||||
}
|
||||
102
f_modules/m_frontend/m_cron/chat-server/sync_subs.php
Normal file
102
f_modules/m_frontend/m_cron/chat-server/sync_subs.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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);
|
||||
Reference in New Issue
Block a user