Hi there,
Below is code from a phpNuke block that displays the phases of the moon with corresponding lunar calendar dates.
I'd like to convert it to be compatible with PostNuke v.726 ...and v.714 if possible.
Here is what the block looks like on the phpNuked webpage:
http://www.myiwc.com ( Third Block Down, Left Side ) .
CLICK HERE for the download page for this phpNuke Block:
Any help is appreciated,
Thanks in advance.
~ HiMY! ~
Code
<?php
/************************************************************************/
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* please credit me, it's my only block */
/* Copyright Robert J. Sori, Las Vegas Nevada */
/************************************************************************/
/* Conversion to Makkah latitude and longitude, sorted out New Moon bug */
/* And Hijri date - adaption by Tayeb Habib tayeb.habib@myiwc.com */
/************************************************************************/
if (eregi("block-Lunar_Hijri.php",$PHP_SELF)) {
header("Location: index.php");
die();
}
$lat = 39.82;
$long = 21.42;
$tz = +3;
$loc ="Makkah";
$a = gmdate(D); //day of the week
$b = gmdate(M); //Month of the Year
$c = gmdate(j); //day of the month
$d = gmdate(Y); //year
$e = gmdate(z); //day of the year
$f = gmdate(I); //daylight savings
$g = gmdate(n); // month number
$h = gmdate(H); //24hr hr's
$i = gmdate(i); //minutes
$j = gmdate(s); //seconds
$k = date(O); //GMT offset
$l = 29.530588; // astronomical constant
$m = 27.55454988; // astronomical constant
$n = 27.212220817; // astronomical constant
$o = 27.321660; // astronomical constant
$p = (2*3.14159); //2 Pie's
$q = 3600; //cache time delay in seconds, 3600=one hour
//formula for Julian Date
$jd = 367*$d-intval(7*($d+intval(($g+9)/12))/4)
- intval(3*(intval(($d+$g-9/7)/100)+1)/4)
+ intval(275*$g/9) + $c + 1721028.5 + ($h/24)+($i/1440) +($j/84600);
//hijri date
// COPYRIGHT 2002 BY KHALED MAMDOUH www.vbzoom.com //
// Updated, and added Islamic names of months by Samir Greadly
// xushi at xushi dot homelinux dot org
// The Names of the months
$mname[1] = "Muharram";
$mname[2] = "Safar";
$mname[3] = "Rabiul Awal";
$mname[4] = "Rabiul Akhir";
$mname[5] = "Jamadil Awal";
$mname[6] = "Jamadil Akhir";
$mname[7] = "Rajab";
$mname[8] = "Sha'ban";
$mname[9] = "Ramadhan";
$mname[10] = "Shawwal";
$mname[11] = "Dzulka'edah";
$mname[12] = "Dzulhijjah";
$TDays=round(strtotime($GetDate)/(60*60*24));
$HYear=round($TDays/354.37419);
$Remain=$TDays-($HYear*354.37419);
$HMonths=round($Remain/29.531182);
$HDays=$Remain-($HMonths*29.531182);
$HYear=$HYear+1389;
$HMonths=$HMonths+10;
$HDays=$HDays+23;
// If the days is over 29, then update month and reset days
if ($HDays>29.531188 and round($HDays)!=30)
{
$HMonths=$HMonths+1;
$HDays=round($HDays-29.531182);
}
else
{
$HDays=round($HDays);
}
// If months is over 12, then add a year, and reset months
if($HMonths>12)
{
$HMonths=$HMonths-12;
$HYear=$HYear+1;
}
$Hd=$HDays;
$Hm=$mname[$HMonths];
// End of Hijri Date Conversion
//formula for Illumination of Moon
$v = ($jd-2452642.34931)/$l; //recent new moon
$v = $v-intval($v);
while ($v<=0)
{$v=($v+1);
}
$ip = $v;
$vv = $v;
$ag = ($ip*$l);
$ip = ($ip*$p);
$age =round($ag, 5);
//formula for distance of Moon
// anomalistic month 27.5545
$v=($jd-2452663.44722)/$m; //recent perigee
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$dp = $v;
$dp = ($dp*$p);
$di = 60.4-3.3*cos($dp)-.6*cos(2*$ip-$dp)-.5*cos(2*$ip);
$er = intval($di*6378);;
$ri = round($di, 3);
//formula for latitude of Moon
// draconic month 27.2122
$v=($jd-2452649.37326)/$n; //recent node at 0 lat
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$np = $v;
$np = $np*$p;
$la = 5.1*sin($np);
$ladisplay = round($la, 5);
//formula for longitude of Moon
// tropical month 27.3215
//measured by determining when the moon is again at a maximum (or minimum) azimuth position
$v=($jd-2452648.22049)/$o; //recent node at 0 long
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$rp = $v;
$lo = (360*$rp)+(6.3*sin($dp))+(1.3*sin(2*$ip-$dp))+(.7*sin(2*$ip));
$longdisplay=round($lo, 5);
if ($ag<=.5){
$phase="Baby Moon";
$daily="lunar/new.jpg";
}
if ($ag>.5){
$phase="Baby Moon";
$daily="lunar/new.jpg";
}
if ($ag>1){
$phase="Thin Cresent";
$daily="lunar/tcx.jpg";
}
if ($ag>2){
$phase="Crescent";
$daily="lunar/cx.jpg";
}
if ($ag>3){
$phase="Waxing";
$daily="lunar/wx1.jpg";
}
if ($ag>4){
$phase="Waxing";
$daily="lunar/wx2.jpg";
}
if ($ag>5){
$phase="Waxing";
$daily="lunar/wx3.jpg";
}
if ($ag>6){
$phase="Waxing";
$daily="lunar/wx4.jpg";
}
if ($ag>7){
$phase="First Quarter";
$daily="lunar/fq.jpg";
}
if ($ag>8){
$phase="Waxing Gibbious";
$daily="lunar/wx5.jpg";
}
if ($ag>9){
$phase="Waxing Gibbious";
$daily="lunar/wx5.jpg";
}
if ($ag>10){
$phase="Waxing Gibbious";
$daily="lunar/wx7.jpg";
}
if ($ag>11){
$phase="Waxing Gibbious";
$daily="lunar/wx8.jpg";
}
if ($ag>12){
$phase="Waxing Gibbious";
$daily="lunar/wx9.jpg";
}
if ($ag>13){
$phase="Waxing Gibbious";
$daily="lunar/wx10.jpg";
}
if ($ag>14){
$phase="Full Moon";
$daily="lunar/full.jpg";
}
if ($ag>15){
$phase="Past Full";
$daily="lunar/wn1.jpg";
}
if ($ag>16){
$phase="Waning Gibbious";
$daily="lunar/wn2.jpg";
}
if ($ag>17){
$phase="Waning Gibbious";
$daily="lunar/wn3.jpg";
}
if ($ag>18){
$phase="Waning Gibbious";
$daily="lunar/wn4.jpg";
}
if ($ag>19){
$phase="Waning Gibbious";
$daily="lunar/wn5.jpg";
}
if ($ag>20){
$phase="Waning Gibbious";
$daily="lunar/wn5.jpg";
}
if ($ag>21){
$phase="Last Quarter";
$daily="lunar/lq.jpg";
}
if ($ag>22){
$phase="Waning";
$daily="lunar/wn7.jpg";
}
if ($ag>23){
$phase="Waning";
$daily="lunar/wn8.jpg";
}
if ($ag>24){
$phase="Waning";
$daily="lunar/wn9.jpg";
}
if ($ag>25.5){
$phase="Waning";
$daily="lunar/wn10.jpg";
}
if ($ag>27){
$phase="Cresent";
$daily="lunar/cn.jpg";
}
if ($ag>28){
$phase="Thin Cresent";
$daily="lunar/tcn.jpg";
}
if ($ag>29.5){
$phase="New Moon";
$daily="lunar/new.jpg";
}
$content .= "<table border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bgcolor=\"#000000\" bordercolor=\"#111111\" width=\"140\" height=\"120\">";
$content .= "<tr><td align=\"center\"><a href=\"$daily\" target=\"_blank\"><img src=\"$daily\" border=\"0\" width=\"110\" height=\"110\" alt=\"Click Image\"></tr></td></table>";
$content .= "<table border=\"1\" align=\"center\" width=\"140\" height=\"120\">";
$content .= "<tr><td align=\"center\"><a href=\"http://aa.usno.navy.mil/\" target=\"_blank\"><b>$phase</b></a>";
$content .= "<tr><td align=\"center\">Hijri $Hd $Hm, $HYear</tr>";
$content .= "<tr><td align=\"center\">Age since New $age</tr>";
$content .= "<tr><td align=\"center\">GMT $h:$i:$j</tr>";
// $content .= "<tr><td align=\"center\">JDate $jd </tr>";
$content .= "<tr><td align=\"center\">Distance in Radii $ri</tr>";
$content .= "<tr><td align=\"center\">$er km at Equator</tr>";
$content .= "<tr><td align=\"center\">Longitude : $longdisplay <br></tr>";
$content .= "<tr><td align=\"center\">R Ascension : $ladisplay <br></tr>";
$content .= "<tr><td align=\"center\"><mailto:\"tayeb.habib@myiwc.com\" style=\"text-decoration: none\" title=\"Lunar Block v3\" target=\"_blank\"><font=\"#0000ff\">Lunar Block - adapted by Tayeb</font></a></tr></td></table>";
?>
/************************************************************************/
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* please credit me, it's my only block */
/* Copyright Robert J. Sori, Las Vegas Nevada */
/************************************************************************/
/* Conversion to Makkah latitude and longitude, sorted out New Moon bug */
/* And Hijri date - adaption by Tayeb Habib tayeb.habib@myiwc.com */
/************************************************************************/
if (eregi("block-Lunar_Hijri.php",$PHP_SELF)) {
header("Location: index.php");
die();
}
$lat = 39.82;
$long = 21.42;
$tz = +3;
$loc ="Makkah";
$a = gmdate(D); //day of the week
$b = gmdate(M); //Month of the Year
$c = gmdate(j); //day of the month
$d = gmdate(Y); //year
$e = gmdate(z); //day of the year
$f = gmdate(I); //daylight savings
$g = gmdate(n); // month number
$h = gmdate(H); //24hr hr's
$i = gmdate(i); //minutes
$j = gmdate(s); //seconds
$k = date(O); //GMT offset
$l = 29.530588; // astronomical constant
$m = 27.55454988; // astronomical constant
$n = 27.212220817; // astronomical constant
$o = 27.321660; // astronomical constant
$p = (2*3.14159); //2 Pie's
$q = 3600; //cache time delay in seconds, 3600=one hour
//formula for Julian Date
$jd = 367*$d-intval(7*($d+intval(($g+9)/12))/4)
- intval(3*(intval(($d+$g-9/7)/100)+1)/4)
+ intval(275*$g/9) + $c + 1721028.5 + ($h/24)+($i/1440) +($j/84600);
//hijri date
// COPYRIGHT 2002 BY KHALED MAMDOUH www.vbzoom.com //
// Updated, and added Islamic names of months by Samir Greadly
// xushi at xushi dot homelinux dot org
// The Names of the months
$mname[1] = "Muharram";
$mname[2] = "Safar";
$mname[3] = "Rabiul Awal";
$mname[4] = "Rabiul Akhir";
$mname[5] = "Jamadil Awal";
$mname[6] = "Jamadil Akhir";
$mname[7] = "Rajab";
$mname[8] = "Sha'ban";
$mname[9] = "Ramadhan";
$mname[10] = "Shawwal";
$mname[11] = "Dzulka'edah";
$mname[12] = "Dzulhijjah";
$TDays=round(strtotime($GetDate)/(60*60*24));
$HYear=round($TDays/354.37419);
$Remain=$TDays-($HYear*354.37419);
$HMonths=round($Remain/29.531182);
$HDays=$Remain-($HMonths*29.531182);
$HYear=$HYear+1389;
$HMonths=$HMonths+10;
$HDays=$HDays+23;
// If the days is over 29, then update month and reset days
if ($HDays>29.531188 and round($HDays)!=30)
{
$HMonths=$HMonths+1;
$HDays=round($HDays-29.531182);
}
else
{
$HDays=round($HDays);
}
// If months is over 12, then add a year, and reset months
if($HMonths>12)
{
$HMonths=$HMonths-12;
$HYear=$HYear+1;
}
$Hd=$HDays;
$Hm=$mname[$HMonths];
// End of Hijri Date Conversion
//formula for Illumination of Moon
$v = ($jd-2452642.34931)/$l; //recent new moon
$v = $v-intval($v);
while ($v<=0)
{$v=($v+1);
}
$ip = $v;
$vv = $v;
$ag = ($ip*$l);
$ip = ($ip*$p);
$age =round($ag, 5);
//formula for distance of Moon
// anomalistic month 27.5545
$v=($jd-2452663.44722)/$m; //recent perigee
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$dp = $v;
$dp = ($dp*$p);
$di = 60.4-3.3*cos($dp)-.6*cos(2*$ip-$dp)-.5*cos(2*$ip);
$er = intval($di*6378);;
$ri = round($di, 3);
//formula for latitude of Moon
// draconic month 27.2122
$v=($jd-2452649.37326)/$n; //recent node at 0 lat
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$np = $v;
$np = $np*$p;
$la = 5.1*sin($np);
$ladisplay = round($la, 5);
//formula for longitude of Moon
// tropical month 27.3215
//measured by determining when the moon is again at a maximum (or minimum) azimuth position
$v=($jd-2452648.22049)/$o; //recent node at 0 long
$v = $v-(intval($v));
while ($v<=0)
{$v=($v+1);
}
$rp = $v;
$lo = (360*$rp)+(6.3*sin($dp))+(1.3*sin(2*$ip-$dp))+(.7*sin(2*$ip));
$longdisplay=round($lo, 5);
if ($ag<=.5){
$phase="Baby Moon";
$daily="lunar/new.jpg";
}
if ($ag>.5){
$phase="Baby Moon";
$daily="lunar/new.jpg";
}
if ($ag>1){
$phase="Thin Cresent";
$daily="lunar/tcx.jpg";
}
if ($ag>2){
$phase="Crescent";
$daily="lunar/cx.jpg";
}
if ($ag>3){
$phase="Waxing";
$daily="lunar/wx1.jpg";
}
if ($ag>4){
$phase="Waxing";
$daily="lunar/wx2.jpg";
}
if ($ag>5){
$phase="Waxing";
$daily="lunar/wx3.jpg";
}
if ($ag>6){
$phase="Waxing";
$daily="lunar/wx4.jpg";
}
if ($ag>7){
$phase="First Quarter";
$daily="lunar/fq.jpg";
}
if ($ag>8){
$phase="Waxing Gibbious";
$daily="lunar/wx5.jpg";
}
if ($ag>9){
$phase="Waxing Gibbious";
$daily="lunar/wx5.jpg";
}
if ($ag>10){
$phase="Waxing Gibbious";
$daily="lunar/wx7.jpg";
}
if ($ag>11){
$phase="Waxing Gibbious";
$daily="lunar/wx8.jpg";
}
if ($ag>12){
$phase="Waxing Gibbious";
$daily="lunar/wx9.jpg";
}
if ($ag>13){
$phase="Waxing Gibbious";
$daily="lunar/wx10.jpg";
}
if ($ag>14){
$phase="Full Moon";
$daily="lunar/full.jpg";
}
if ($ag>15){
$phase="Past Full";
$daily="lunar/wn1.jpg";
}
if ($ag>16){
$phase="Waning Gibbious";
$daily="lunar/wn2.jpg";
}
if ($ag>17){
$phase="Waning Gibbious";
$daily="lunar/wn3.jpg";
}
if ($ag>18){
$phase="Waning Gibbious";
$daily="lunar/wn4.jpg";
}
if ($ag>19){
$phase="Waning Gibbious";
$daily="lunar/wn5.jpg";
}
if ($ag>20){
$phase="Waning Gibbious";
$daily="lunar/wn5.jpg";
}
if ($ag>21){
$phase="Last Quarter";
$daily="lunar/lq.jpg";
}
if ($ag>22){
$phase="Waning";
$daily="lunar/wn7.jpg";
}
if ($ag>23){
$phase="Waning";
$daily="lunar/wn8.jpg";
}
if ($ag>24){
$phase="Waning";
$daily="lunar/wn9.jpg";
}
if ($ag>25.5){
$phase="Waning";
$daily="lunar/wn10.jpg";
}
if ($ag>27){
$phase="Cresent";
$daily="lunar/cn.jpg";
}
if ($ag>28){
$phase="Thin Cresent";
$daily="lunar/tcn.jpg";
}
if ($ag>29.5){
$phase="New Moon";
$daily="lunar/new.jpg";
}
$content .= "<table border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bgcolor=\"#000000\" bordercolor=\"#111111\" width=\"140\" height=\"120\">";
$content .= "<tr><td align=\"center\"><a href=\"$daily\" target=\"_blank\"><img src=\"$daily\" border=\"0\" width=\"110\" height=\"110\" alt=\"Click Image\"></tr></td></table>";
$content .= "<table border=\"1\" align=\"center\" width=\"140\" height=\"120\">";
$content .= "<tr><td align=\"center\"><a href=\"http://aa.usno.navy.mil/\" target=\"_blank\"><b>$phase</b></a>";
$content .= "<tr><td align=\"center\">Hijri $Hd $Hm, $HYear</tr>";
$content .= "<tr><td align=\"center\">Age since New $age</tr>";
$content .= "<tr><td align=\"center\">GMT $h:$i:$j</tr>";
// $content .= "<tr><td align=\"center\">JDate $jd </tr>";
$content .= "<tr><td align=\"center\">Distance in Radii $ri</tr>";
$content .= "<tr><td align=\"center\">$er km at Equator</tr>";
$content .= "<tr><td align=\"center\">Longitude : $longdisplay <br></tr>";
$content .= "<tr><td align=\"center\">R Ascension : $ladisplay <br></tr>";
$content .= "<tr><td align=\"center\"><mailto:\"tayeb.habib@myiwc.com\" style=\"text-decoration: none\" title=\"Lunar Block v3\" target=\"_blank\"><font=\"#0000ff\">Lunar Block - adapted by Tayeb</font></a></tr></td></table>";
?>
--
Be Debt Free!
Join IslamBank.community!
