File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/ew/SectorIndices.php
Back
<?php // DataGetter/SectorIndices.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['exc'])) $exc = $_GET['exc']; else $exc = 'NSE'; /* -------------------- 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; } $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']['SI'][$exc] ?? []; } if (empty($indices)): ?> <div class="ki-empty"> <div class="ki-empty__icon">i</div> <div class="ki-empty__text">No Data Found</div> <div class="ki-empty__sub">Try switching the exchange.</div> </div> <?php else: function fmtPerf($v) { $v = floatval($v); if ($v > 0) return ['+' . number_format($v, 2), 'pos']; if ($v < 0) return [number_format($v, 2), 'neg']; return ['0.00', 'flat']; } foreach ($indices as $i => $list): $IName = htmlspecialchars($list['IName'] ?? '', ENT_QUOTES); $LTP = htmlspecialchars($list['LTP'] ?? '', ENT_QUOTES); $chng = floatval($list['Chng'] ?? 0); $chngPer = floatval($list['PChng'] ?? 0); $High = htmlspecialchars($list['High'] ?? '', ENT_QUOTES); $Low = htmlspecialchars($list['Low'] ?? '', ENT_QUOTES); $PerfW = $list['PerfW'] ?? 0; $PerfM = $list['PerfM'] ?? 0; $PerfY = $list['PerfY'] ?? 0; 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%'; } [$wDisp, $wDir] = fmtPerf($PerfW); [$mDisp, $mDir] = fmtPerf($PerfM); [$yDisp, $yDir] = fmtPerf($PerfY); $delay = number_format(min($i, 15) * 0.04, 2); ?> <div class="ki-card" style="animation-delay:<?php echo $delay; ?>s"> <div class="ki-card__head"> <div class="ki-head__left"> <div class="ki-head__name"><?php echo $IName; ?></div> <div class="ki-head__ltp-label">Last Traded Price</div> </div> <div class="ki-head__right"> <div class="ki-head__ltp"><?php echo $LTP; ?></div> <div class="ki-head__chng ki-head__chng--<?php echo $dir; ?>"> <?php if ($dir === 'up'): ?> <svg viewBox="0 0 10 10" width="9" height="9"><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="9" height="9"><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="9" height="9"><line x1="2" y1="5" x2="8" y2="5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> <?php endif; ?> <?php echo $chngDisp; ?> (<?php echo $pctDisp; ?>) </div> </div> </div> <div class="ki-card__hl"> <div class="ki-hl__item"> <div class="ki-hl__label">Today High</div> <div class="ki-hl__val ki-hl__val--high"><?php echo $High; ?></div> </div> <div class="ki-hl__div"></div> <div class="ki-hl__item"> <div class="ki-hl__label">Today Low</div> <div class="ki-hl__val ki-hl__val--low"><?php echo $Low; ?></div> </div> </div> <div class="ki-card__perf"> <div class="ki-perf__title">Performance</div> <div class="ki-perf__cells"> <div class="ki-perf__cell"> <div class="ki-perf__period">WTD</div> <div class="ki-perf__val ki-perf__val--<?php echo $wDir; ?>"> <?php echo $wDisp; ?><span class="ki-perf__pct">%</span> </div> </div> <div class="ki-perf__sep"></div> <div class="ki-perf__cell"> <div class="ki-perf__period">MTD</div> <div class="ki-perf__val ki-perf__val--<?php echo $mDir; ?>"> <?php echo $mDisp; ?><span class="ki-perf__pct">%</span> </div> </div> <div class="ki-perf__sep"></div> <div class="ki-perf__cell"> <div class="ki-perf__period">YTD</div> <div class="ki-perf__val ki-perf__val--<?php echo $yDir; ?>"> <?php echo $yDisp; ?><span class="ki-perf__pct">%</span> </div> </div> </div> </div> </div> <?php endforeach; endif; ?> <style> .ki-card { background: var(--surface); border: 1px solid var(--accent-hair); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; position: relative; animation: kiIn .35s ease backwards; } .ki-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); } @keyframes kiIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } } .ki-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 14px 12px 18px; border-bottom: 1px solid var(--accent-hair); } .ki-head__left { flex: 1; min-width: 0; } .ki-head__name { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 500; color: var(--accent-deep); letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ki-head__ltp-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.10em; color: var(--ink-3); margin-top: 4px; opacity: 0.7; } .ki-head__right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; } .ki-head__ltp { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; line-height: 1; } .ki-head__chng { display: inline-flex; align-items: center; gap: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; padding: 4px 10px 4px 7px; border-radius: var(--radius-pill); letter-spacing: -0.01em; line-height: 1; } .ki-head__chng--up { color: var(--buy); background: var(--buy-bg); } .ki-head__chng--down { color: var(--sell); background: var(--sell-bg); } .ki-head__chng--flat { color: var(--ink-3); background: var(--accent-soft); } .ki-card__hl { display: flex; align-items: center; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--accent-hair); gap: 0; background: var(--surface-tint); } .ki-hl__item { flex: 1; display: flex; flex-direction: column; gap: 3px; } .ki-hl__item:last-child { text-align: right; align-items: flex-end; } .ki-hl__label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.10em; color: var(--ink-3); opacity: 0.75; } .ki-hl__val { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; } .ki-hl__val--high { color: var(--buy); } .ki-hl__val--low { color: var(--sell); } .ki-hl__div { width: 1px; background: var(--accent-hair); height: 32px; margin: 0 16px; flex-shrink: 0; } .ki-card__perf { padding: 10px 14px 12px 18px; } .ki-perf__title { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent-dark); opacity: 0.75; margin-bottom: 8px; } .ki-perf__cells { display: flex; align-items: center; gap: 0; } .ki-perf__cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; } .ki-perf__period { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); opacity: 0.7; } .ki-perf__val { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 1px; } .ki-perf__pct { font-size: 10px; font-weight: 700; opacity: 0.7; } .ki-perf__val--pos { color: var(--buy); } .ki-perf__val--neg { color: var(--sell); } .ki-perf__val--flat { color: var(--ink-3); } .ki-perf__sep { width: 1px; background: var(--accent-hair); height: 36px; flex-shrink: 0; margin: 0 2px; } .ki-empty { padding: 30px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--accent-light); border-radius: var(--radius); } .ki-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; } .ki-empty__text { font-family: 'Fraunces', serif; font-size: 16px; color: var(--accent-deep); font-weight: 500; } .ki-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.02 |
proxy
|
phpinfo
|
Settings