ob_start();
// Header("Location: https://www.swingfish.trade/blog/swingfish-updates/2024/10/website-codebase-issues/"); die();
// echo '
'; die("upgrading the page... will be back shortly ...");
//print_r($_SERVER);
if ((strstr($_SERVER['REQUEST_URI'], 'select'))||(strstr($_SERVER['REQUEST_URI'], 'union'))) {
file_put_contents('assets/cache/blocked-requests', $_SERVER['REQUEST_URI']."\n\l", FILE_APPEND | LOCK_EX);
die("thanks for playing back to Swingfish.trade");
}
session_start();
date_default_timezone_set('Asia/Singapore');
function ScriptTime() {
// just create a Microtime fraction to count execution times
// THIS NEED TO BE ON TOP OF THIS FUNCTION File !!
$a = explode (' ',microtime());
return(double) $a[0] + $a[1];
}
$TI['head'] = ScriptTime();
function isMario() {
if ($_SERVER['REMOTE_ADDR'] == "184.82.180.144") {
return true;
}
else {
return false;
}
}
function HtmlAlert($text, $type, $subject ='Heads up!') {
return ''.$subject.' '.$text.'
';
}
function HtmlToolTip($text, $type='', $subject ='Heads up!') {
return $text;
}
function MoneyFormat($amount) {
return number_format((float)$amount, 2, '.', '');
}
include ("defaults.php");
$TI['defaults'] = ScriptTime();
$pos0 = @file_get_contents(CACHE.'positions.tmp'); // this file is updated via /0x8-positions.php called in footer
if (strlen($pos0)<4) { $pos0 = false;}
if ((substr($_SERVER['SERVER_NAME'], 0, 8) != "www.swin") && ($_SERVER['HTTP_HOST'] != "dev.swingfish.trade")) {
$u = $_SERVER['REQUEST_URI'];
if ($u[0] == "/") {
$u = substr($u, 1);
}
// echo "##".URL.$u;
header("Location: ".URL.$u);
die(URL.$u);
}
include(URI.'lib/3rd/Subversion/site_version.php'); // just adding a array $SVN
$TI['site_version'] = ScriptTime();
if (!isset($_SESSION['hl'])) {
// cloudflare data
if (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
$_SESSION['hl'] = strtolower($_SERVER['HTTP_CF_IPCOUNTRY']);
}
else {
$_SESSION['hl'] = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'en', 0, 2));
}
}
if (isset($_REQUEST['hl'])) {
$_SESSION['hl'] = strtolower($_REQUEST['hl']);
}
// if language not ain list .. fall back to english
if (!in_array($_SESSION['hl'], $AvaiableLanguages)) {
$_SESSION['hl'] = 'en';
}
// fallback to english
if (!isset($_SESSION['hl'])) {
$_SESSION['hl'] = 'en';
}
$hl = $_SESSION['hl'];
include_once("lib/human.inc.php");
if ((isset($_GET['go']))&&($_GET['go'] != "")) {
$go = explode('/', $_GET['go']);
if ($go[0] == "") { array_splice($go, 0,1); }
// print_r($go);
$load = $go[0];
if (isset($go[1])) { $cid = $go[1]; }
}
else {
// $load = "landing";
$load = "landing";
}
// short Urls
if (ctype_digit($load)) {
// it's a number so we load a blog entry
header("Location: https://www.swingfish.trade/blog/?p=".$load);
die("https://www.swingfish.trade/blog/?p=".$load);
}
if ($load == "profit-share") {
// strategy
header("Location: https://www.enfoid.com/investors/profit-share");
die("https://www.enfoid.com/investors/profit-share");
}
if ($load == "s") {
// strategy
header("Location: ".URL."strategy/".$cid);
die(URL."strategy/".$cid);
}
if ((isset($go[1]))&&($go[1]=="discordout")) {
unset($_SESSION['discord']);
}
// dead Urls
$deadurls = array(
'icmarkets' => 'lib/ib/icmarkets', // redirect to IB link
// 'terms' => 'faq', // leave this with dummy file so the link gets indexed on search engines
// 'product-protected' => 'risk-free',
// 'signals' => 'blog/c/forex-signal-cfd-analysis',
'risk-free' => 'money',
'backed-funds' => 'money',
'calculate-compounded-earnings' => 'money',
'login-required' => 'crew',
'user' => 'crew',
'broker-icmarkets' => 'broker/icmarkets',
'broker-pepperstone'=> 'broker/pepperstone',
'broker-fondex' => 'broker/fondex',
'broker-kawase' => 'broker/kawase',
'broker_ic-markets' => 'broker/icmarkets',
'brokers-ctrader' => 'brokers',
'brokers-ctrader' => 'brokers',
'vwap' => 'vwap-forex',
'join' => 'go/chat',
'reuters-xenith' => 'software_realtime_news-reuters-xenith',
'chat' => 'discord', // must stay as the chat link is widely used !
'd' => 'discord',
'discord' => '/293419', // also need to update /go/chat/index.php for short links
'divergence' => 'currency-divergence_xscalp.com',
'obos' => 'currency-obos2_xscalp.com',
'cabincrew' => 'members/cabincrew',
'log' => 'lib/3rd/wordpress/Tradelog_draft.php', // same as journal
'journal' => 'lib/3rd/wordpress/Tradelog_draft.php',
'channel' => 'tradingroom?s=youtubechannelcall', // wrong channel call (no clue where that is from)
'free-money' => 'go/enfoid-free-money', // link to blog post on enfoid website
'book' => 'the-lies-we-trade-by',
'downloads' => 'assets/downloads/',
'currency-divergences' => '/431181', // old xscalp links
'currency-overbought-oversold' => '/431181', // old divergence tool links
'money_wpost' => 'money', // temp redirect till there is a landing page for WP blog ads
'contact' => 'about',
'prop-firm_opinion_instantfunding' => 'prop-firm/instantfunding',
'prop-firm_opinion_blueguardian' => 'prop-firm/blueguardian',
'prop-firm_opinion_ftmo' => 'prop-firm/ftmo',
'prop-firm_opinion_fundingpips' => 'prop-firm/fundingpips',
'prop-firm_opinion_fundingpips' => 'prop-firm/fundingpips',
'7-seconds' => 'decoded/trading-reality/7-seconds',
);
if (isset($deadurls[$load])) {
Header("Location: ".URL.$deadurls[$load]);
die(URL.$deadurls[$load]);
}
unset($deadurls);
$sitepart = '';
$github_content = false;
$github_preview = false;
$github_file = false;
if (is_file(GITHUB_CONTENT_DIR.$load.".html")) {
$github_file = GITHUB_CONTENT_DIR.$load.".html";
} elseif (is_file(GITHUB_CONTENT_DIR.$load.".php")) {
$github_file = GITHUB_CONTENT_DIR.$load.".php";
}
if ($load === 'search') {
// search results — handled by content/search.php, skip file-exists check
} elseif (isset($_GET['preview']) && $_GET['preview'] === 'github'
&& !empty($_COOKIE['sf_logged_in']) && $github_file) {
$github_content = true;
$github_preview = true;
} elseif (is_file("content/".$load.".php")) {
// local PHP wins
} elseif ($github_file) {
$github_content = true;
} else {
$load = "landing";
}
// fake functions to make wp includes work
include('lib/3rd/wordpress/wp-functions.php');
$TI['wp-functions'] = ScriptTime();
// prep wordpress includes
include('lib/3rd/wordpress/wordpress/wp-content/plugins/swingfish/swingfish.php');
$TI['wp-functions'] = ScriptTime();
// Trading room state ($info_mode, $media_mode, $live, $draft, $pos0, ...) -
// computed globally so the header/nav and other pages can show a status
// indicator, not just content/tradingroom.php.
include(URI.'lib/tradingroom.state.php');
if (($load == "landing2")|| ($load == "landings")) {
include('lib/3rd/wordpress/wordpress/wp-content/themes/nucleus/header.landing.php');
}
else {
include('lib/3rd/wordpress/wordpress/wp-content/themes/sf2/header.php');
}
$TI['header'] = ScriptTime();
if ($github_content) {
if ($github_preview) {
echo ' Preview — you are viewing the GitHub version of this page. The local PHP version is what visitors normally see.
Back to live version ';
}
$_github_basename = basename($github_file);
if (substr($github_file, -4) === '.php') {
include($github_file);
} else {
readfile($github_file);
}
echo ' Suggest an edit
';
} elseif (is_file("content/".$load.".".$hl.".php")) {
include("content/".$load.".".$hl.".php");
} else {
include("content/".$load.".php");
}
$TI['content'] = ScriptTime();
//if (is_file("assets/theme/footer.".$hl.".php")) { include("assets/theme/footer.".$hl.".php"); } else { include("assets/theme/footer.php"); }
include('lib/3rd/wordpress/wordpress/wp-content/themes/sf2/footer.php');
$TI['footer'] = ScriptTime();
// log timing to file (only if total > 500ms)
$t0 = reset($TI);
$total_ms = round(($TI['footer'] - $t0) * 1000, 1);
if ($total_ms > 100) {
$prev = $t0;
$log = [date('Y-m-d H:i:s'), $_SERVER['REQUEST_URI'] ?? '-'];
foreach ($TI as $k => $v) {
$elapsed = round(($v - $t0) * 1000, 1);
$delta = round(($v - $prev) * 1000, 1);
$log[] = "$k:${elapsed}+${delta}";
$prev = $v;
}
file_put_contents(__DIR__ . '/timings_log.txt', implode('|', $log) . "\n", FILE_APPEND | LOCK_EX);
}
if (isMario()) {
echo "";
$t0 = reset($TI);
$prev = $t0;
foreach ($TI as $k => $v) {
$elapsed = round(($v - $t0) * 1000, 1);
$delta = round(($v - $prev) * 1000, 1);
printf("%-20s %8s ms (+%s ms)\n", "[$k]", $elapsed, $delta);
$prev = $v;
}
echo "";
}