311 lines
16 KiB
PHP
311 lines
16 KiB
PHP
<?php
|
|
require_once 'constants.php';
|
|
require_once 'astro_functions.php';
|
|
require_once 'ephemeris_engine.php';
|
|
|
|
$nameMode = NAME_MODE_VEDIC;
|
|
date_default_timezone_set('Asia/Kathmandu');
|
|
|
|
$date = $_GET['date'] ?? '';
|
|
$time = $_GET['time'] ?? '';
|
|
$location = $_GET['location'] ?? '';
|
|
|
|
$locationMap = [
|
|
'Kathmandu' => ['latitude' => 27.7172, 'longitude' => 85.3240],
|
|
'Pokhara' => ['latitude' => 28.2096, 'longitude' => 83.9856],
|
|
'Lalitpur' => ['latitude' => 27.6644, 'longitude' => 85.3188],
|
|
'Bhaktapur' => ['latitude' => 27.6710, 'longitude' => 85.4298],
|
|
'Biratnagar' => ['latitude' => 26.4525, 'longitude' => 87.2718],
|
|
'Chitwan' => ['latitude' => 27.5291, 'longitude' => 84.3542],
|
|
'Butwal' => ['latitude' => 27.7000, 'longitude' => 83.4480]
|
|
];
|
|
|
|
$latitude = '';
|
|
$longitude = '';
|
|
|
|
$localDateTime = '';
|
|
$utcDateTime = '';
|
|
$unixTimestamp = '';
|
|
$julianDay = '';
|
|
$decimalHour = '';
|
|
$apiError = '';
|
|
|
|
$samplePlanets = [];
|
|
$planetsByHierarchy = [];
|
|
$positionsInOrder = [];
|
|
$ascendantLongitude = null;
|
|
$ascendantData = null;
|
|
|
|
if (!empty($location) && isset($locationMap[$location])) {
|
|
$latitude = $locationMap[$location]['latitude'];
|
|
$longitude = $locationMap[$location]['longitude'];
|
|
}
|
|
|
|
function getJulianDayFromDateTime($date, $time, $timezone = 'Asia/Kathmandu')
|
|
{
|
|
$dt = new DateTime("$date $time", new DateTimeZone($timezone));
|
|
$dtUtc = clone $dt;
|
|
$dtUtc->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
$year = (int)$dtUtc->format('Y');
|
|
$month = (int)$dtUtc->format('m');
|
|
$day = (int)$dtUtc->format('d');
|
|
$hour = (int)$dtUtc->format('H');
|
|
$minute = (int)$dtUtc->format('i');
|
|
$second = (int)$dtUtc->format('s');
|
|
|
|
$decimalHour = $hour + ($minute / 60) + ($second / 3600);
|
|
|
|
if ($month <= 2) {
|
|
$year -= 1;
|
|
$month += 12;
|
|
}
|
|
|
|
$A = floor($year / 100);
|
|
$B = 2 - $A + floor($A / 4);
|
|
|
|
$jd = floor(365.25 * ($year + 4716))
|
|
+ floor(30.6001 * ($month + 1))
|
|
+ $day + $B - 1524.5
|
|
+ ($decimalHour / 24);
|
|
|
|
return [
|
|
'local_datetime' => $dt->format('Y-m-d H:i:s'),
|
|
'utc_datetime' => $dtUtc->format('Y-m-d H:i:s'),
|
|
'unix_timestamp' => $dt->getTimestamp(),
|
|
'julian_day' => round($jd, 6),
|
|
'decimal_hour' => round($decimalHour, 6)
|
|
];
|
|
}
|
|
|
|
if (!empty($date) && !empty($time) && !empty($location) && isset($locationMap[$location])) {
|
|
$calcData = getJulianDayFromDateTime($date, $time);
|
|
|
|
$localDateTime = $calcData['local_datetime'];
|
|
$utcDateTime = $calcData['utc_datetime'];
|
|
$unixTimestamp = $calcData['unix_timestamp'];
|
|
$julianDay = $calcData['julian_day'];
|
|
$decimalHour = $calcData['decimal_hour'];
|
|
|
|
$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">
|
|
<title>Prajwal's Astro Analysis</title>
|
|
|
|
<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">
|
|
<div class="text-center mb-5">
|
|
<h1 class="fw-bold text-warning">Prajwal's Astro Analysis</h1>
|
|
<p class="text-light">
|
|
Analyze planetary positioning, nakshatra, and horoscope from selected date, time, and location.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="main-card p-4 p-md-5">
|
|
<div class="row g-4 align-items-start">
|
|
|
|
<div class="col-lg-12">
|
|
<form method="GET" action="" class="row">
|
|
<div class="col-lg-4">
|
|
<label class="form-label">Select Date</label>
|
|
<input type="date" class="form-control" id="datePicker" name="date" value="<?= htmlspecialchars($date) ?>">
|
|
</div>
|
|
|
|
<div class="col-lg-4">
|
|
<label class="form-label">Select Time</label>
|
|
<input type="time" class="form-control" id="timePicker" name="time" value="<?= htmlspecialchars($time) ?>">
|
|
</div>
|
|
|
|
<div class="col-lg-4">
|
|
<label class="form-label">Select Location</label>
|
|
<select class="form-select" id="locationSelector" name="location">
|
|
<option value="" disabled <?= $location === '' ? 'selected' : '' ?>>Choose location</option>
|
|
<option value="Kathmandu" <?= $location === 'Kathmandu' ? 'selected' : '' ?>>Kathmandu</option>
|
|
<option value="Pokhara" <?= $location === 'Pokhara' ? 'selected' : '' ?>>Pokhara</option>
|
|
<option value="Lalitpur" <?= $location === 'Lalitpur' ? 'selected' : '' ?>>Lalitpur</option>
|
|
<option value="Bhaktapur" <?= $location === 'Bhaktapur' ? 'selected' : '' ?>>Bhaktapur</option>
|
|
<option value="Biratnagar" <?= $location === 'Biratnagar' ? 'selected' : '' ?>>Biratnagar</option>
|
|
<option value="Chitwan" <?= $location === 'Chitwan' ? 'selected' : '' ?>>Chitwan</option>
|
|
<option value="Butwal" <?= $location === 'Butwal' ? 'selected' : '' ?>>Butwal</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-lg-12">
|
|
<button type="submit" class="btn btn-custom w-100 mt-2">Analyze</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="col-lg-12">
|
|
<div class="row g-3 mb-4">
|
|
<div class="info-box">
|
|
<div class="section-title">Geocentric Positioning of Planets</div>
|
|
|
|
<?php if ($date || $time || $location): ?>
|
|
<div class="result-box mt-3">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<p><strong>Date:</strong> <?= htmlspecialchars($date ?: '-') ?></p>
|
|
<p><strong>Time:</strong> <?= htmlspecialchars($time ?: '-') ?></p>
|
|
<p><strong>Location:</strong> <?= htmlspecialchars($location ?: '-') ?></p>
|
|
<p><strong>Latitude:</strong> <?= $latitude !== '' ? htmlspecialchars((string)$latitude) : '-' ?></p>
|
|
<p><strong>Longitude:</strong> <?= $longitude !== '' ? htmlspecialchars((string)$longitude) : '-' ?></p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p><strong>Local DateTime:</strong> <?= $localDateTime ?: '-' ?></p>
|
|
<p><strong>UTC DateTime:</strong> <?= $utcDateTime ?: '-' ?></p>
|
|
<p><strong>Unix Timestamp:</strong> <?= $unixTimestamp !== '' ? $unixTimestamp : '-' ?></p>
|
|
<p><strong>Decimal Hour (UTC):</strong> <?= $decimalHour !== '' ? $decimalHour : '-' ?></p>
|
|
<p><strong>Julian Day:</strong> <?= $julianDay !== '' ? $julianDay : '-' ?></p>
|
|
</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">
|
|
<p class="mb-0">Please select date, time, and location, then click Analyze.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="chart-wrapper">
|
|
<div class="astro-circle" id="astroCircle">
|
|
<div class="earth-center">
|
|
<img src="https://upload.wikimedia.org/wikipedia/commons/9/97/The_Earth_seen_from_Apollo_17.jpg" alt="Earth">
|
|
</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>
|
|
<th>Segment</th>
|
|
<th>Sign</th>
|
|
<th>Degree</th>
|
|
<th>Nakshatra</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?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 colspan="5">No planetary data available.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
<div class="table-box">
|
|
<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>
|
|
<th>Planet</th>
|
|
<th>Sign</th>
|
|
<th>Degree</th>
|
|
<th>Nakshatra</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?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 colspan="5">No ordered planetary data available.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<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>
|