I was searching for a algorithm to get the phase of the moon, and unfortunately the Moon Phase Class on PHP Classes is inaccurate. With some searching I was able to find 2 sites that have code to pull it off (
Lunar Phase Calculator and Moon Phase Calculation.
part1 http://jivebay.com/2008/09/07/calculating-the-moon-phase/
part2 http://jivebay.com/2010/01/04/calculating-the-moon-phase-part-2/