File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/API/ew/MostActive.php
Back
<?php // DataGetter/MostActive.php /* -------------------- CORS -------------------- Called via cross-origin browser AJAX from sharemarketipo.in (and possibly other properties). Must be set before ANY other output. ------------------------------------------------ */ $allowedOrigins = [ 'https://sharemarketipo.in', 'https://applyipo.in', ]; $origin = $_SERVER['HTTP_ORIGIN'] ?? ''; if (in_array($origin, $allowedOrigins, true)) { header('Access-Control-Allow-Origin: ' . $origin); header('Access-Control-Allow-Methods: GET'); header('Access-Control-Allow-Headers: Content-Type'); } $grd = 1; if (isset($_GET['exc'])) $exc = $_GET['exc']; else $exc = 'NSE'; if (isset($_GET['icode'])) $icode = $_GET['icode']; else $icode = 22115; if (isset($_GET['prd'])) $prd = $_GET['prd']; else $prd = 1; if (isset($_GET['type'])) $type = $_GET['type']; else $type = 'VOL'; $cir = 2; /* -------------------- Robust fetch: real timeouts + one retry -------------------- NOTE: headers below reference ewmw.edelweiss.in / www.edelweiss.in while the request URL targets nwmw.nuvamawealth.com — that mismatch was already present in the original file. Left unchanged since the correct values aren't known; worth double-checking with whoever supplied this endpoint. ------------------------------------------------------------------------------- */ $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/PriceGainOrLoss', 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 => 'POST', CURLOPT_POSTFIELDS =>'{"grd":' . $grd . ',"exc":"' . $exc . '","icode":' . $icode . ',"prd": ' . $prd . ',"cir": ' . $cir . '}', CURLOPT_HTTPHEADER => array( 'authority: ewmw.edelweiss.in', 'accept: application/json, text/plain, */*', 'accept-language: en-US,en;q=0.9,gu;q=0.8,zh-TW;q=0.7,zh;q=0.6', 'content-type: application/json;charset=UTF-8', 'origin: https://www.edelweiss.in', 'referer: https://www.edelweiss.in/', 'sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"', 'sec-ch-ua-mobile: ?1', 'sec-ch-ua-platform: "Android"', 'sec-fetch-dest: empty', 'sec-fetch-mode: cors', 'sec-fetch-site: same-site', 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36' ), )); $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; } $rows = []; 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); $rows = is_array($data) ? ($data['JsonData'] ?? []) : []; } if (empty($rows)): ?> <div class="empty"> <div class="empty__icon">i</div> <div class="empty__text">No Data Found</div> <div class="empty__sub">Could not reach data source. Please try again.</div> </div> <?php else: foreach ($rows as $row): $name = $row['SName'] ?? ''; $sector = $row['Sector'] ?? ''; $ltp = $row['LTP'] ?? ''; $chng = $row['Chng'] ?? 0; $chngPer = $row['PChng'] ?? 0; $vlm = $row['Vlm'] ?? ''; $TrnOvr = $row['TrnOvr'] ?? ''; ?> <div class="stock-row"> <div> <div class="stock-row__name"><?php echo $name; ?></div> <div class="stock-row__sub"><?php echo $sector; ?></div> </div> <div> <div class="stock-row__num"><?php echo $ltp; ?></div> <div class="stock-row__change <?php if($chng > 0) echo 'stock-row__change--pos'; elseif($chng < 0) echo 'stock-row__change--neg'; else echo 'stock-row__change--neu'; ?>"><?php if($chng > 0) { echo '+' . $chng . ' (' . $chngPer . '%)'; } elseif($chng < 0) { echo $chng . ' (' . $chngPer . '%)'; } else { echo $chng . ' (' . $chngPer . '%)'; } ?></div> </div> <div class="stock-row__cell"> <?php if($type == "VOL") { ?> <div class="stock-row__num"><?php echo $vlm; ?></div> <div class="stock-row__sub"><?php echo "Lacs"; ?></div> <?php } else { ?> <div class="stock-row__num"><?php echo $TrnOvr; ?></div> <div class="stock-row__sub"><?php echo "Crores"; ?></div> <?php } ?> </div> </div> <?php endforeach; endif; ?> <style> .empty { padding: 30px 20px; text-align: center; } .empty__icon { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent, #F16334); color: #fff; display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-size: 24px; font-style: italic; } .empty__text { font-family: 'Fraunces', serif; font-size: 16px; color: var(--accent-deep, #333); font-weight: 500; } .empty__sub { margin-top: 4px; font-size: 12px; color: var(--accent-dark, #666); opacity: 0.75; } </style>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings