Files
PAA/index.php
2026-03-09 07:06:26 +05:45

291 lines
13 KiB
PHP

<?php
require_once 'constants.php';
require_once 'astro_functions.php';
$nameMode = NAME_MODE_MODERN;
$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 = '';
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'];
}
/*
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)
];
$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>
</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 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; ?>
</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 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; ?>
</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])); ?>;
</script>
<script src="js.js"></script>
</body>
</html>