File manager - Edit - /home/cipherteam/htdocs/cipherteam.in/APPS/CronJobs/Kfintech/KfintechAllotment.php
Back
<?php ini_set('display_errors', 1); error_reporting(E_ALL); /* ================= 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"); function splitIpoNames($raw) { // supports: "Corona, Meesho ,Kahan" $parts = preg_split('/\s*,\s*/', trim((string)$raw)); $out = []; foreach ($parts as $p) { $p = trim($p); if ($p !== '') $out[] = $p; } // unique, keep order return array_values(array_unique($out)); } /* ================= CONFIG ================= */ // Node binary (Node 18+) $NODE = "/usr/bin/node"; // JS scraper (same folder) $JS = __DIR__ . "/kfin_fetch_ipo_list.js"; // 🔔 Notification API $NOTIFY_URL = "https://cipherteam.in/APPS/CronJobs/IPONEWSFINDERS/senNotification.php"; $NOTIFY_KEY = "PR@TIK@2552"; /* ================= FETCH IPO NAMES FROM DB (Kfintech only) ================= IMPORTANT: If your DB server_name is "KFintech" or "KFINTECH", update it below. */ $ipoNames = []; $res = mysqli_query($con, " SELECT ipo_name FROM scraper_servers WHERE is_enabled = 1 AND server_name = 'Kfintech' 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)); while ($row = mysqli_fetch_assoc($res)) { $ipoNames[] = trim($row['ipo_name']); } if (empty($ipoNames)) { echo "No Kfintech IPO names found.\n"; exit; } /* ================= RUN NODE SCRIPT ONCE ================= */ $cmd = escapeshellcmd($NODE) . " " . escapeshellarg($JS) . " 2>&1"; $out = shell_exec($cmd); if (!$out) { die("ERROR: Node output empty\n"); } $data = json_decode(trim($out), true); if (!$data || empty($data['ok'])) { die("ERROR: Invalid node output:\n" . $out . "\n"); } $options = $data['options'] ?? []; if (!is_array($options)) { die("ERROR: Options not array\n"); } /* ================= SEARCH ALL IPOs FROM DB ================= */ $matched = []; foreach ($ipoNames as $targetName) { foreach ($options as $row) { if (!is_array($row)) continue; $name = $row['name'] ?? ''; $value = $row['value'] ?? ''; if (!is_string($name) || !is_string($value)) continue; // Match by name (case-insensitive, partial match) if ($targetName !== "" && stripos($name, $targetName) !== false) { $matched[] = [ "target" => $name, "name" => $name, "value" => $value ]; break; } } } /* ================= NOTIFY ================= */ if (!empty($matched)) { foreach ($matched as $m) { $title = $m['target'] . " Allotment Out"; $msg = "Allotment Live @ KFintech"; $url = $NOTIFY_URL . "?key=" . urlencode($NOTIFY_KEY) . "&title=" . urlencode($title) . "&message=" . urlencode($msg); file_get_contents($url); } echo "FOUND + NOTIFIED: " . count($matched) . "\n"; foreach ($matched as $m) { echo "IPO : {$m['name']}\n"; echo "ID : {$m['value']}\n"; echo "Match : {$m['target']}\n"; echo "----------------------\n"; } } else { echo "NOT FOUND\n"; } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.9 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings