Api Fixed
This commit is contained in:
130
index.php
130
index.php
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
require_once 'constants.php';
|
||||
require_once 'astro_functions.php';
|
||||
require_once 'ephemeris_engine.php';
|
||||
|
||||
$nameMode = NAME_MODE_MODERN;
|
||||
$nameMode=NAME_MODE_VEDIC;
|
||||
$nameMode = NAME_MODE_VEDIC;
|
||||
date_default_timezone_set('Asia/Kathmandu');
|
||||
|
||||
$date = $_GET['date'] ?? '';
|
||||
@@ -28,6 +28,13 @@ $utcDateTime = '';
|
||||
$unixTimestamp = '';
|
||||
$julianDay = '';
|
||||
$decimalHour = '';
|
||||
$apiError = '';
|
||||
|
||||
$samplePlanets = [];
|
||||
$planetsByHierarchy = [];
|
||||
$positionsInOrder = [];
|
||||
$ascendantLongitude = null;
|
||||
$ascendantData = null;
|
||||
|
||||
if (!empty($location) && isset($locationMap[$location])) {
|
||||
$latitude = $locationMap[$location]['latitude'];
|
||||
@@ -79,32 +86,34 @@ if (!empty($date) && !empty($time) && !empty($location) && isset($locationMap[$l
|
||||
$unixTimestamp = $calcData['unix_timestamp'];
|
||||
$julianDay = $calcData['julian_day'];
|
||||
$decimalHour = $calcData['decimal_hour'];
|
||||
}
|
||||
|
||||
/*
|
||||
SAMPLE PLANET DATA
|
||||
house = wheel segment number
|
||||
*/
|
||||
$samplePlanets = [
|
||||
buildPlanetDataFromLongitude('sun', 5.20, $nameMode),
|
||||
buildPlanetDataFromLongitude('moon', 72.13, $nameMode),
|
||||
buildPlanetDataFromLongitude('mars', 78.35, $nameMode),
|
||||
buildPlanetDataFromLongitude('mercury', 32.08, $nameMode),
|
||||
buildPlanetDataFromLongitude('venus', 41.30, $nameMode),
|
||||
buildPlanetDataFromLongitude('jupiter', 129.18, $nameMode),
|
||||
buildPlanetDataFromLongitude('saturn', 22.43, $nameMode),
|
||||
buildPlanetDataFromLongitude('rahu', 304.23, $nameMode),
|
||||
buildPlanetDataFromLongitude('ketu', 124.23, $nameMode)
|
||||
];
|
||||
$realPlanetData = getRealPlanetaryData($date, $time, (float)$latitude, (float)$longitude);
|
||||
$realPlanetLongitudes = $realPlanetData['planets'];
|
||||
$ascendantLongitude = $realPlanetData['ascendant'];
|
||||
$apiError = $realPlanetData['error'];
|
||||
|
||||
if (!empty($realPlanetLongitudes)) {
|
||||
foreach ($realPlanetLongitudes as $planet) {
|
||||
$samplePlanets[] = buildPlanetDataFromLongitude(
|
||||
$planet['key'],
|
||||
$planet['longitude'],
|
||||
$nameMode
|
||||
);
|
||||
}
|
||||
} elseif (empty($apiError)) {
|
||||
$apiError = 'Could not fetch planetary data from remote API.';
|
||||
}
|
||||
|
||||
if ($ascendantLongitude !== null) {
|
||||
$ascendantData = buildPlanetDataFromLongitude('sun', $ascendantLongitude, $nameMode);
|
||||
}
|
||||
}
|
||||
|
||||
$planetsByHierarchy = $samplePlanets;
|
||||
$positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -113,7 +122,6 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container py-5">
|
||||
@@ -183,8 +191,20 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($ascendantLongitude !== null && $ascendantData !== null): ?>
|
||||
<div class="mt-3">
|
||||
<p><strong>Ascendant Longitude:</strong> <?= htmlspecialchars((string)round($ascendantLongitude, 6)) ?></p>
|
||||
<p><strong>Ascendant Sign:</strong> <?= htmlspecialchars($ascendantData['sign']) ?></p>
|
||||
<p><strong>Ascendant Degree:</strong> <?= htmlspecialchars($ascendantData['degree']) ?></p>
|
||||
<p><strong>Ascendant Nakshatra:</strong> <?= htmlspecialchars($ascendantData['nakshatra']) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if (!empty($apiError)): ?>
|
||||
<div class="alert alert-danger mt-3 mb-0">
|
||||
<?= htmlspecialchars($apiError) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="result-box mt-3">
|
||||
@@ -200,13 +220,13 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4 mt-4">
|
||||
<div class="col-lg-6">
|
||||
<div class="table-box">
|
||||
<h5 class="table-title">Table 1: Positions by Planets</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-dark table-bordered align-middle astro-table mb-0">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Planet</th>
|
||||
@@ -216,21 +236,22 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
<th>Nakshatra</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($planetsByHierarchy as $planet): ?>
|
||||
|
||||
<?php if (!empty($planetsByHierarchy)): ?>
|
||||
<?php foreach ($planetsByHierarchy as $planet): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($planet['name']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['house']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['sign']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['degree']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['nakshatra']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($planet['name']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['house']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['sign']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['degree']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['nakshatra']) ?></td>
|
||||
<td colspan="5">No planetary data available.</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -242,7 +263,6 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
<h5 class="table-title">Table 2: Positions in Order</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-dark table-bordered align-middle astro-table mb-0">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Segment</th>
|
||||
@@ -252,21 +272,22 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
<th>Nakshatra</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($positionsInOrder as $planet): ?>
|
||||
|
||||
<?php if (!empty($positionsInOrder)): ?>
|
||||
<?php foreach ($positionsInOrder as $planet): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($planet['house']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['name']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['sign']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['degree']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['nakshatra']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($planet['house']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['name']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['sign']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['degree']) ?></td>
|
||||
<td><?= htmlspecialchars($planet['nakshatra']) ?></td>
|
||||
<td colspan="5">No ordered planetary data available.</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -280,12 +301,11 @@ $positionsInOrder = sortPlanetsByLongitude($samplePlanets);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const samplePlanets = <?= json_encode($samplePlanets, JSON_UNESCAPED_UNICODE); ?>;
|
||||
const signNames = <?= json_encode(array_values(SIGN_NAMES[$nameMode])); ?>;
|
||||
</script>
|
||||
<script src="js.js"></script>
|
||||
<script>
|
||||
const samplePlanets = <?= json_encode($samplePlanets, JSON_UNESCAPED_UNICODE); ?>;
|
||||
const signNames = <?= json_encode(array_values(SIGN_NAMES[$nameMode]), JSON_UNESCAPED_UNICODE); ?>;
|
||||
</script>
|
||||
<script src="js.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user