File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/APPS/CronJobs/maashitla/MaashitlaAllotment.php
Back
<?php // MaashitlaAllotment.php include("simple_html_dom.php"); // kept (safe) even if not used now /* ---------------- DB CONNECTION ---------------- */ $con = mysqli_connect("localhost:3306", "marketdatauser", "d7o7A8%s2d7", "marketdataci"); if (mysqli_connect_errno()) { echo "Connection Fail " . mysqli_connect_error(); exit; } mysqli_set_charset($con, "utf8mb4"); /* ---------------- Helper: split comma-separated names ---------------- */ function splitIpoNames($raw) { $parts = preg_split('/\s*,\s*/', trim((string)$raw)); $out = []; foreach ($parts as $p) { $p = trim($p); if ($p !== '') $out[] = $p; } return array_values(array_unique($out)); } /* ---------------- Helper: safe curl GET ---------------- */ function curl_get_json($url, $timeout = 20) { $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_TIMEOUT => $timeout, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_HTTPHEADER => [ "accept: application/json, text/plain, */*", "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36" ], ]); $body = curl_exec($ch); $err = curl_error($ch); $code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($body === false || $err) { return [false, "cURL error: " . $err, null, $code]; } if ($code < 200 || $code >= 300) { return [false, "HTTP error: " . $code, $body, $code]; } $json = json_decode($body, true); if (!is_array($json)) { return [false, "Invalid JSON response", $body, $code]; } return [true, "OK", $json, $code]; } /* ---------------- Get IPO Names ONLY for Maashitla ---------------- */ $res = mysqli_query($con, " SELECT ipo_name FROM scraper_servers WHERE is_enabled = 1 AND server_name = 'Maashitla' AND ipo_name <> '' "); $ipoNames = []; while ($row = mysqli_fetch_assoc($res)) { foreach (splitIpoNames($row['ipo_name']) as $nm) { $ipoNames[] = $nm; } } $ipoNames = array_values(array_unique($ipoNames)); if (empty($ipoNames)) { echo "No Maashitla IPO names found.\n"; exit; } /* ---------------- NEW: Fetch companies list from microservices ---------------- */ $apiUrl = "https://microservices.maashitla.com/public-issues-service/companies"; list($ok, $msg, $json, $httpCode) = curl_get_json($apiUrl, 20); if (!$ok) { echo "Failed to fetch Maashitla companies API. " . $msg . "\n"; // If you want, print response for debug (optional): // echo "Response: " . substr((string)$json, 0, 500) . "\n"; exit; } if (!isset($json['success']) || $json['success'] !== true || !isset($json['data']) || !is_array($json['data'])) { echo "Unexpected API format from Maashitla.\n"; // echo "Full JSON: " . json_encode($json) . "\n"; exit; } /* ---------------- Build options list from API: companyTitle ---------------- */ $options = []; foreach ($json['data'] as $row) { if (!is_array($row)) continue; $title = trim((string)($row['companyTitle'] ?? '')); if ($title !== '') { $options[] = $title; } } $options = array_values(array_unique($options)); if (empty($options)) { echo "No companies found in Maashitla API.\n"; exit; } /* ---------------- Check each IPO name ---------------- */ foreach ($ipoNames as $name) { $nameLower = strtolower(trim($name)); if ($nameLower === '') continue; foreach ($options as $optText) { // match like your old logic (contains) if (strpos(strtolower($optText), $nameLower) !== false) { $title = $name . " Allotment Out"; $msg = "Allotment Live At Maashitla"; @file_get_contents( "https://cipherteam.in/APPS/CronJobs/IPONEWSFINDERS/senNotification.php?key=PR@TIK@2552" . "&title=" . urlencode($title) . "&message=" . urlencode($msg) ); break; // stop after first match } } } echo "Done. Checked Maashitla IPOs: " . count($ipoNames) . " \n"; exit(0); ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings