File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/ew/GlobleIndices.php
Back
<?php // DataGetter/GlobleIndices.php header('Access-Control-Allow-Origin: https://sharemarketipo.in'); header('Access-Control-Allow-Methods: GET'); header('Access-Control-Allow-Headers: Content-Type'); if (isset($_GET['index'])) $index = $_GET['index']; else $index = 'Asia'; $safeIndex = in_array($index, ['Europe','America','Asia']) ? $index : 'Asia'; /* -------------------- Robust fetch: real timeouts + one retry -------------------- */ $response = false; $httpCode = null; for ($attempt = 1; $attempt <= 2; $attempt++) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://nwmw.nuvamawealth.com/api/Market/MarketsModule/MarketsIndices', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 8, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); $errno = curl_errno($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($errno === 0 && $httpCode === 200 && !empty($response)) break; if ($errno === 0 && $httpCode !== 0 && $httpCode < 500) break; // non-5xx rejection, don't retry } $indices = []; if ($httpCode === 200 && !empty($response)) { $str = str_replace('\n', '', strval($response)); $str2 = str_replace('\r', '', $str); $str3 = str_replace('\\', '', $str2); $str4 = substr($str3, 1, strlen($str3) - 2); $data = json_decode($str4, true); $indices = $data['JsonData']['GI'][$safeIndex] ?? []; } // BUG FIX: replace broken external image URLs with Unicode emoji flags // (nuvamawealth.com images are not publicly accessible from this app) function getFlag($country) { $c = strtolower($country); if (strpos($c, 'united states') !== false || strpos($c, 'america') !== false) return '🇺🇸'; if (strpos($c, 'united kingdom') !== false || strpos($c, 'britain') !== false) return '🇬🇧'; if (strpos($c, 'germany') !== false) return '🇩🇪'; if (strpos($c, 'france') !== false) return '🇫🇷'; if (strpos($c, 'japan') !== false) return '🇯🇵'; if (strpos($c, 'china') !== false) return '🇨🇳'; if (strpos($c, 'hong kong') !== false) return '🇭🇰'; if (strpos($c, 'south korea') !== false) return '🇰🇷'; if (strpos($c, 'india') !== false) return '🇮🇳'; if (strpos($c, 'singapore') !== false) return '🇸🇬'; if (strpos($c, 'australia') !== false) return '🇦🇺'; if (strpos($c, 'brazil') !== false) return '🇧🇷'; if (strpos($c, 'canada') !== false) return '🇨🇦'; if (strpos($c, 'netherlands') !== false) return '🇳🇱'; if (strpos($c, 'spain') !== false) return '🇪🇸'; if (strpos($c, 'italy') !== false) return '🇮🇹'; if (strpos($c, 'switzerland') !== false) return '🇨🇭'; if (strpos($c, 'austria') !== false) return '🇦🇹'; if (strpos($c, 'belgium') !== false) return '🇧🇪'; if (strpos($c, 'taiwan') !== false) return '🇹🇼'; if (strpos($c, 'thailand') !== false) return '🇹🇭'; if (strpos($c, 'indonesia') !== false) return '🇮🇩'; if (strpos($c, 'malaysia') !== false) return '🇲🇾'; if (strpos($c, 'philippines') !== false) return '🇵🇭'; if (strpos($c, 'sri lanka') !== false) return '🇱🇰'; if (strpos($c, 'mexico') !== false) return '🇲🇽'; if (strpos($c, 'argentina') !== false) return '🇦🇷'; if (strpos($c, 'israel') !== false) return '🇮🇱'; return '🌐'; // globe fallback } if (empty($indices)): ?> <div class="gi-empty"> <div class="gi-empty__icon">i</div> <div class="gi-empty__text">No Data Found</div> <div class="gi-empty__sub">Try a different region.</div> </div> <?php else: foreach ($indices as $i => $list): $IName = htmlspecialchars($list['IName'] ?? '', ENT_QUOTES); $country = htmlspecialchars($list['Coun'] ?? '', ENT_QUOTES); $LTP = htmlspecialchars($list['LTP'] ?? '', ENT_QUOTES); $chng = floatval($list['Chng'] ?? 0); $chngPer = floatval($list['PChng'] ?? 0); $dateRaw = $list['Date'] ?? ''; $dateObj = $dateRaw ? new DateTime($dateRaw) : null; $dateFmt = $dateObj ? $dateObj->format('j M') : '—'; $timeFmt = $dateObj ? $dateObj->format('h:i A') : ''; $flag = getFlag(strtolower($country)); if ($chng > 0) { $dir = 'up'; $chngDisp = '+' . number_format($chng,2); $pctDisp = '+' . number_format($chngPer,2) . '%'; } elseif ($chng < 0) { $dir = 'down'; $chngDisp = number_format($chng,2); $pctDisp = number_format($chngPer,2) . '%'; } else { $dir = 'flat'; $chngDisp = '0.00'; $pctDisp = '0.00%'; } $delay = number_format(min($i, 20) * 0.025, 3); ?> <div class="gi-row" style="animation-delay:<?php echo $delay; ?>s"> <div class="gi-row__flag"><?php echo $flag; ?></div> <div class="gi-row__info"> <div class="gi-row__name"><?php echo $IName; ?></div> <div class="gi-row__country"><?php echo $country; ?></div> </div> <div class="gi-row__price"> <div class="gi-row__ltp"><?php echo $LTP; ?></div> <span class="gi-row__chng gi-row__chng--<?php echo $dir; ?>"> <?php if ($dir === 'up'): ?> <svg viewBox="0 0 10 10" width="8" height="8"><polyline points="2,7 5,3 8,7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> <?php elseif ($dir === 'down'): ?> <svg viewBox="0 0 10 10" width="8" height="8"><polyline points="2,3 5,7 8,3" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> <?php else: ?> <svg viewBox="0 0 10 10" width="8" height="8"><line x1="2" y1="5" x2="8" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> <?php endif; ?> <?php echo $pctDisp; ?> </span> </div> <div class="gi-row__date"> <div class="gi-row__date-d"><?php echo $dateFmt; ?></div> <div class="gi-row__date-t"><?php echo $timeFmt; ?></div> </div> </div> <?php endforeach; endif; ?> <style> .gi-row { display: flex; align-items: center; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--accent-hair); gap: 8px; animation: giIn .3s ease backwards; transition: background .15s ease; } .gi-row:last-child { border-bottom: none; } .gi-row:hover { background: var(--accent-softer); } @keyframes giIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } } .gi-row__flag { width: 28px; flex-shrink: 0; font-size: 18px; line-height: 1; text-align: center; } .gi-row__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; } .gi-row__name { font-family: 'DM Sans', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--accent-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .gi-row__country { font-size: 10px; font-weight: 500; color: var(--ink-3); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .gi-row__price { width: 80px; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; } .gi-row__ltp { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; line-height: 1; } .gi-row__chng { display: inline-flex; align-items: center; gap: 2px; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; padding: 2px 6px 2px 4px; border-radius: 999px; white-space: nowrap; letter-spacing: -0.01em; line-height: 1; } .gi-row__chng--up { color: var(--buy); background: var(--buy-bg); } .gi-row__chng--down { color: var(--sell); background: var(--sell-bg); } .gi-row__chng--flat { color: var(--ink-3); background: var(--accent-soft); } .gi-row__date { width: 46px; flex-shrink: 0; text-align: right; display: flex; flex-direction: column; gap: 2px; } .gi-row__date-d { font-family: 'DM Sans', sans-serif; font-size: 10px; font-weight: 600; color: var(--ink-2); } .gi-row__date-t { font-size: 9px; font-weight: 500; color: var(--ink-3); opacity: 0.7; } .gi-empty { padding: 30px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--accent-light); border-radius: var(--radius); } .gi-empty__icon { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-size: 24px; font-style: italic; } .gi-empty__text { font-family: 'Fraunces', serif; font-size: 16px; color: var(--accent-deep); font-weight: 500; } .gi-empty__sub { margin-top: 4px; font-size: 12px; color: var(--accent-dark); opacity: 0.75; } </style>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.07 |
proxy
|
phpinfo
|
Settings