Jump to content

MrTIMarshall

Members
  • Posts

    69
  • Joined

  • Last visited

Everything posted by MrTIMarshall

  1. tornhq.com/InteractiveMapExternal.php= Get=MapSelectionInfoCurrent ​- To load the #current information tabs maps-slider - To load the slider maps ​&Country=World will show all of the countries, any other country entered such as United-States will load the tabs for all of the states or all the images for the slider. This is a basic URL I would like to be able to generate whereas there will eventually be '&Region', and deeper sorting. I am not yet completed with the current page of countries for the Earth and the slider has been removed for the time being, but what has been currently made you can view here: https://tornhq.com/WorkingOn/InteractiveMap/implementing.html#Main Upon clicking a country on the slider (when I refer to this I currently mean the bottom bullet points), it will switch the content under the #Current tab of the #Map-Selection-Info. There'll be a link to be able to focus in on the selected country from, if you clicked on United States; tornhq.com/InteractiveMapExternal.php=Get=MapSelectionInfoCurrent&Country=United-States tornhq.com/InteractiveMapExternal.php=Get=maps-slider&Country=United-States And remove; tornhq.com/InteractiveMapExternal.php=Get=MapSelectionInfoCurrent&Country=Earth tornhq.com/InteractiveMapExternal.php=Get=maps-slider&Country=Earth With the exception of 'Earth' not being a country. On one of these links will simply be the content needed to be shown on the page, so no styling, just the div's and whatnot. On the page, on first load it will load the default information. I would like help to firstly know if this is the best way round doing something like this and also setting something up like this as I do not have a clue what to search for. There may well be some good tutorials out there already, however I have no key-words to go by as this is a new thing for me. The only thing I currently know is what the contents will show, although I have not made them all, and that my page which will fetch the data will need to be in php, but I am not sure if this is the best or even a good way other than setting up a database with this information in, of which would be a bit of a nightmare for myself. Thank you for any time spent in following up my questions and your help and/or advice you provide, I am very grateful! Best Regards, Tim
  2. Hello, Firstly, I would like to know how to setup a page, of which you can do something alike the following; mydoman.com/InteractiveMapDataFetch.php?=COUNTRY=United-Kingdom&Region1=England - Fetches England Data mydoman.com/InteractiveMapDataFetch.php?=COUNTRY=United-Kingdom&Region1=England&Region2=North-West - Fetches England, North-West Data Each page will have code on to be fetched by the bigger document, just plain code with no styling as the style sheet is attached to the bigger document and whatnot. This is my idea on how to have my massive page, not be so massive in code at a singular time to enhance loading speeds and whatnot. Secondly, I would like to know how to have a content switcher via a link click where the current data will be removed and the new data will be loaded. Could someone please help me make a very basic version of this to get to grips with and then implement it into my website? Thank you for any time spend in following up my question and for any help and/or advice given. Best Regards, Tim
  3. Okay, well I have the concept on how to do things, and I think I know how to program certain aspects to provide a live demonstration, therefore a specific question would be; How can I, with the aid of any other programming language, allow the user to either drop files onto the page or via browsing into a temporary location on my own server space and show these in the #LivePreview section? Best Regards, Tim
  4. I strongly disagree with you haku and think you should not underestimate what someone has the ability of achieving. There may well be a billion CMS systems out there already, however I would like to create my own basic one and build it up from there. You could say that I would like to make a Facebook profile editor with a live preview, of which should not be difficult at all as you do not need much information to do so. On my searches, I cannot find anything on the basic level, all with features I do not wish to even have. All I need is, basing what you can do on Facebook; Upload images to use, be able to delete them and set maximum width/height for certain images for different sections. Add information for sections Upload other files such as videos I am not building anything for Facebook, I am just using it as an example as it is widely used and therefore known about and you should be able to understand what I wish to accomplish. More features will come at a later date, but for the time being, this is all I wish to have to work upon. Best Regards, Tim
  5. Hello, I'll be using this for a page creator/editor where in the resources tab they can upload multiple files depending on their account type. They will then be able to, for example the header of their page, check for it to be an image they have uploaded and it will show o the live preview below. I am finding it very hard to find a file uploader which stores the file in a temp location on my server and not the likes of the Google API, delete the file and cancel the upload and could really do with some help. I only really need the PHP and whatnot, no styling as I can work on that myself. Thank you for your help, Best Regards, Tim,
  6. I have found this for my image uploader and preview: https://github.com/blueimp/jQuery-File-Upload However I do not have a clue what I am doing, so many files and whatnot I might look for another one.
  7. Thank you DaveyK. I don't suppose you know of any examples I could build up on or if you could provide a very basic one yourself and is it possible to show an image without actually uploading it to the site until they decide to submit the page details beforehand, show the image via their local on the page for them or if not store the image on my server into a temporary location which deletes if they cancel or exit the page so I don't end up with loads of random images which aren't needed? Best Regards, Tim
  8. Hello, I would like to start from scratch, or the basic level, to be able to improve upon and whatnot for a page builder/editor. I am just presuming that the language needed is PHP to be able to edit and create new pages as it is server-side programming which is needed, yet again another presumption as I am not familiar with PHP. This builder doesn't yet need to work, but I want to make sure I program it in a way which it can build/edit a page. The editor will be made at a later date, of which I would like to know if I would need to submit information to a database via the page builder to be able to edit at a later date. For the time being, I would simply like to know how to make a page builder of which a live preview is available in a preview area. The page will have a side menu, JQuery Accordion style, of which will change the content to the left and when you change the content of anything the live preview updates. If this part does not need PHP, please let me know and I'll find somewhere else to post this thread and will come back at a later date to find out the PHP information I need. Thank you for your help, Best Regards, Tim
  9. Hello, http://www.mywebsite.com/viewestablishment.php?=COUNTRY=UK&Region=Northwest.... I would like to know how to make a new page after completing a multi-step Javascript creation forum. I have not yet started this form, however I do have a template from an old project. I have not yet started this form to see if this is the best option to go around doing so. The example link above is something I would like to generate similar to. The #1 of the forum will categorical the new page to know what country this listing is for, where about in the country and the name of the listing. If Javascript is the best way, and I should first make the forum please just let me know as I am not only looking for an answer, but confirmation. I gather I'll need to make a template too, I'm not sure how exactly though, I do know how to make a page, but do I simply make this page with no content, just the empty divs and whatnot? Best Regards, Tim
  10. Hopefully this image I just made is what your looking for? Best Regards, Tim
  11. I have not yet downloaded your .zip as I plan to do so when I am more refreshed tomorrow, however I am wondering if the image background needs to be black to show the phrase or can it be transparent to be used on a sky for example? Thank you for uploading the files. Best Regards, Tim
  12. Sorry for what? Your work is fantastic, I simply thought this might have been something that you may have overlooked. Anyway, for the time being, please do not provide anymore help as I am trying to get some Javascript help to make my page dynamic and I did not know at first that you cannot achieve this via PHP. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style> body, html { margin:0; border:0; } #sky { width: 100%; height: 250px; margin: 0; padding: 0; background: #555599; } #sky .sunwrap { position: relative; width: 80%; height: 250px; margin: 0 auto; overflow: hidden; } #sun { position: relative; width: 50px; height: 50px; ; border-radius:50%; background: #fefcea; background: -moz-linear-gradient(top, #fefcea 0%, #f1da36 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fefcea), color-stop(100%, #f1da36)); background: -webkit-linear-gradient(top, #fefcea 0%, #f1da36 100%); background: -o-linear-gradient(top, #fefcea 0%, #f1da36 100%); background: -ms-linear-gradient(top, #fefcea 0%, #f1da36 100%); background: linear-gradient(to bottom, #fefcea 0%, #f1da36 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefcea', endColorstr='#f1da36', GradientType=0); -webkit-box-shadow: 0px 0px 28px 0px #ffffff; box-shadow: 0px 0px 28px 0px #ffffff; } </style> </head> <body> <?php $lat = 53.3761; $long= -2.1897; $hour = isset($_GET['hour']) ? $_GET['hour'] : 0; $timenow = time(); // var timenow = new Date().getTime() / 1000; $today = mktime(0,0,0); echo "Today = $today<br />"; $todayInfo = date_sun_info($today, $lat, $long); echo "Today = $todayInfo<br />"; $nighttime = false; // var nighttime = false; switch(true) { case $timenow < $todayInfo['sunrise']: // is it pre-sunrise // get last night's sunset $nighttime = true; $yesterdayInfo = date_sun_info(strtotime('-1 days', $today), $lat, $long); $percent = round(($timenow - $yesterdayInfo['sunset'] )*100/($todayInfo['sunrise'] - $yesterdayInfo['sunset'])); break; case $timenow > $todayInfo['sunset']: // get tomorrow's sunrise $nighttime = true; $tomorrowInfo = date_sun_info(strtotime('+1 days', $today), $lat, $long); $percent = round(($timenow - $todayInfo['sunset'] )*100/($tomorrowInfo['sunrise'] - $todayInfo['sunset'])); break; default: $percent = round(($timenow - $todayInfo['sunrise'])*100/($todayInfo['sunset'] - $todayInfo['sunrise'])); break; } if ($nighttime) { $bg = '#000'; $fg = '#FFF'; } else { $bg = '#FFF'; $fg = '#000'; } if ($nighttime) { $bgcols = array ( 20 => '#CCC', 40 => '#888', 50 => '#2F2F4F', // Mightnight Blue 60 => '#333', 80 => '#000', 100 => '#AECAD4', // Dawn Sky Blue ); foreach ($bgcols as $pc => $color) { if ($percent <= $pc) { $bg = $color; break; } } $fg = '#FFF'; } else { $bgcols = array ( 20 => '#000', 40 => '#000', 60 => '#000', 80 => '#000', 98 => '#000', 100 => '#26538D', // Dusk Sky Blue ); foreach ($bgcols as $pc => $color) { if ($percent <= $pc) { $bg = $color; break; } } $fg = '#FFF'; } ?> <div id="sky"> <div class="sunwrap"> <div id="sun"></div> </div> </div> <script type="text/javascript"> var domSun = document.getElementById('sun'), timePassed = <?php echo $percent / 100; ?>, origin = { x: 50, y: 110 }, radius = { x: 40, y: 95 }; var position = { x: origin.x + radius.x * Math.cos(timePassed * Math.PI), y: origin.y - radius.y * Math.sin(timePassed * Math.PI) }; domSun.style.left = position.x + '%'; domSun.style.top = position.y + '%'; </script> <br /> <h1>Currently at: <?php echo $percent / 100; ?>,</h1><br /> </body> </html> I feel guilty as a lot of your work is in that Barand and I am not yet sure how much of it is needed to make it dynamic
  13. Pretty much, yeah! Apart from slight boarder tweaking as there seems to be a little boarder like part to the south-western part.
  14. Yes, I do like it, however I would much prefer the Moon's detail on the image. The image you have attached looks similar to the images I have which is good, but I want to make this as realistic as possible. Best Regards, Tim
  15. Hello, I need to shwo $percent if it is below 0.10 to be 0.01 for example. case $timenow < $todayInfo['sunrise']: // is it pre-sunrise // get last night's sunset $nighttime = true; $yesterdayInfo = date_sun_info(strtotime('-1 days', $today), $lat, $long); $percent = round(($timenow - $yesterdayInfo['sunset'] )*100/($todayInfo['sunrise'] - $yesterdayInfo['sunset'])); break; Thank you fro any help and/or advice in advanced,. Best Regards, Tim
  16. Oh, I didn't realize it was just a white moon. If I had an image of the moon could it do the moon phrases? I have been manually doing them in Photoshop and I almost have the full moon phrase. Also, how can I have the result of how far away the moon is shown on the page dynamically instead of a new value per page load?
  17. No HTML at all? This results in a blank page: https://tornhq.com/Top_Menu/moon.php
  18. moonphrase.php <?php /** * Moon phase calculation class * Adapted for PHP from Moontool for Windows (http://www.fourmilab.ch/moontoolw/) * by Samir Shah (http://rayofsolaris.net) * Last modified August 2012 **/ class MoonPhase { private $timestamp; private $phase; private $illum; private $age; private $dist; private $angdia; private $sundist; private $sunangdia; private $synmonth; private $quarters = null; function __construct( $pdate = null ) { if( is_null( $pdate ) ) $pdate = time(); /* Astronomical constants */ $epoch = 2444238.5; // 1980 January 0.0 /* Constants defining the Sun's apparent orbit */ $elonge = 278.833540; // Ecliptic longitude of the Sun at epoch 1980.0 $elongp = 282.596403; // Ecliptic longitude of the Sun at perigee $eccent = 0.016718; // Eccentricity of Earth's orbit $sunsmax = 1.495985e8; // Semi-major axis of Earth's orbit, km $sunangsiz = 0.533128; // Sun's angular size, degrees, at semi-major axis distance /* Elements of the Moon's orbit, epoch 1980.0 */ $mmlong = 64.975464; // Moon's mean longitude at the epoch $mmlongp = 349.383063; // Mean longitude of the perigee at the epoch $mlnode = 151.950429; // Mean longitude of the node at the epoch $minc = 5.145396; // Inclination of the Moon's orbit $mecc = 0.054900; // Eccentricity of the Moon's orbit $mangsiz = 0.5181; // Moon's angular size at distance a from Earth $msmax = 384401; // Semi-major axis of Moon's orbit in km $mparallax = 0.9507; // Parallax at distance a from Earth $synmonth = 29.53058868; // Synodic month (new Moon to new Moon) $this->synmonth = $synmonth; $lunatbase = 2423436.0; // Base date for E. W. Brown's numbered series of lunations (1923 January 16) /* Properties of the Earth */ // $earthrad = 6378.16; // Radius of Earth in kilometres // $PI = 3.14159265358979323846; // Assume not near black hole $this->timestamp = $pdate; // pdate is coming in as a UNIX timstamp, so convert it to Julian $pdate = $pdate / 86400 + 2440587.5; /* Calculation of the Sun's position */ $Day = $pdate - $epoch; // Date within epoch $N = $this->fixangle((360 / 365.2422) * $Day); // Mean anomaly of the Sun $M = $this->fixangle($N + $elonge - $elongp); // Convert from perigee co-ordinates to epoch 1980.0 $Ec = $this->kepler($M, $eccent); // Solve equation of Kepler $Ec = sqrt((1 + $eccent) / (1 - $eccent)) * tan($Ec / 2); $Ec = 2 * rad2deg(atan($Ec)); // True anomaly $Lambdasun = $this->fixangle($Ec + $elongp); // Sun's geocentric ecliptic longitude $F = ((1 + $eccent * cos(deg2rad($Ec))) / (1 - $eccent * $eccent)); // Orbital distance factor $SunDist = $sunsmax / $F; // Distance to Sun in km $SunAng = $F * $sunangsiz; // Sun's angular size in degrees /* Calculation of the Moon's position */ $ml = $this->fixangle(13.1763966 * $Day + $mmlong); // Moon's mean longitude $MM = $this->fixangle($ml - 0.1114041 * $Day - $mmlongp); // Moon's mean anomaly $MN = $this->fixangle($mlnode - 0.0529539 * $Day); // Moon's ascending node mean longitude $Ev = 1.2739 * sin(deg2rad(2 * ($ml - $Lambdasun) - $MM)); // Evection $Ae = 0.1858 * sin(deg2rad($M)); // Annual equation $A3 = 0.37 * sin(deg2rad($M)); // Correction term $MmP = $MM + $Ev - $Ae - $A3; // Corrected anomaly $mEc = 6.2886 * sin(deg2rad($MmP)); // Correction for the equation of the centre $A4 = 0.214 * sin(deg2rad(2 * $MmP)); // Another correction term $lP = $ml + $Ev + $mEc - $Ae + $A4; // Corrected longitude $V = 0.6583 * sin(deg2rad(2 * ($lP - $Lambdasun))); // Variation $lPP = $lP + $V; // True longitude $NP = $MN - 0.16 * sin(deg2rad($M)); // Corrected longitude of the node $y = sin(deg2rad($lPP - $NP)) * cos(deg2rad($minc)); // Y inclination coordinate $x = cos(deg2rad($lPP - $NP)); // X inclination coordinate $Lambdamoon = rad2deg(atan2($y, $x)) + $NP; // Ecliptic longitude $BetaM = rad2deg(asin(sin(deg2rad($lPP - $NP)) * sin(deg2rad($minc)))); // Ecliptic latitude /* Calculation of the phase of the Moon */ $MoonAge = $lPP - $Lambdasun; // Age of the Moon in degrees $MoonPhase = (1 - cos(deg2rad($MoonAge))) / 2; // Phase of the Moon // Distance of moon from the centre of the Earth $MoonDist = ($msmax * (1 - $mecc * $mecc)) / (1 + $mecc * cos(deg2rad($MmP + $mEc))); $MoonDFrac = $MoonDist / $msmax; $MoonAng = $mangsiz / $MoonDFrac; // Moon's angular diameter // $MoonPar = $mparallax / $MoonDFrac; // Moon's parallax // store results $this->phase = $this->fixangle($MoonAge) / 360; // Phase (0 to 1) $this->illum = $MoonPhase; // Illuminated fraction (0 to 1) $this->age = $synmonth * $this->phase; // Age of moon (days) $this->dist = $MoonDist; // Distance (kilometres) $this->angdia = $MoonAng; // Angular diameter (degrees) $this->sundist = $SunDist; // Distance to Sun (kilometres) $this->sunangdia = $SunAng; // Sun's angular diameter (degrees) } private function fixangle($a) { return ( $a - 360 * floor($a / 360) ); } // KEPLER -- Solve the equation of Kepler. private function kepler($m, $ecc) { //double e, delta; $epsilon = pow(1, -6); $e = $m = deg2rad($m); do { $delta = $e - $ecc * sin($e) - $m; $e -= $delta / ( 1 - $ecc * cos($e) ); } while ( abs($delta) > $epsilon ); return $e; } /* Calculates time of the mean new Moon for a given base date. This argument K to this function is the precomputed synodic month index, given by: K = (year - 1900) * 12.3685 where year is expressed as a year and fractional year. */ private function meanphase($sdate, $k){ // Time in Julian centuries from 1900 January 0.5 $t = ( $sdate - 2415020.0 ) / 36525; $t2 = $t * $t; $t3 = $t2 * $t; $nt1 = 2415020.75933 + $this->synmonth * $k + 0.0001178 * $t2 - 0.000000155 * $t3 + 0.00033 * sin( deg2rad( 166.56 + 132.87 * $t - 0.009173 * $t2 ) ); return $nt1; } /* Given a K value used to determine the mean phase of the new moon, and a phase selector (0.0, 0.25, 0.5, 0.75), obtain the true, corrected phase time. */ private function truephase($k, $phase){ $apcor = false; $k += $phase; // Add phase to new moon time $t = $k / 1236.85; // Time in Julian centuries from 1900 January 0.5 $t2 = $t * $t; // Square for frequent use $t3 = $t2 * $t; // Cube for frequent use $pt = 2415020.75933 // Mean time of phase + $this->synmonth * $k + 0.0001178 * $t2 - 0.000000155 * $t3 + 0.00033 * sin( deg2rad( 166.56 + 132.87 * $t - 0.009173 * $t2 ) ); $m = 359.2242 + 29.10535608 * $k - 0.0000333 * $t2 - 0.00000347 * $t3; // Sun's mean anomaly $mprime = 306.0253 + 385.81691806 * $k + 0.0107306 * $t2 + 0.00001236 * $t3; // Moon's mean anomaly $f = 21.2964 + 390.67050646 * $k - 0.0016528 * $t2 - 0.00000239 * $t3; // Moon's argument of latitude if ( $phase < 0.01 || abs( $phase - 0.5 ) < 0.01 ) { // Corrections for New and Full Moon $pt += (0.1734 - 0.000393 * $t) * sin( deg2rad( $m ) ) + 0.0021 * sin( deg2rad( 2 * $m ) ) - 0.4068 * sin( deg2rad( $mprime ) ) + 0.0161 * sin( deg2rad( 2 * $mprime) ) - 0.0004 * sin( deg2rad( 3 * $mprime ) ) + 0.0104 * sin( deg2rad( 2 * $f ) ) - 0.0051 * sin( deg2rad( $m + $mprime ) ) - 0.0074 * sin( deg2rad( $m - $mprime ) ) + 0.0004 * sin( deg2rad( 2 * $f + $m ) ) - 0.0004 * sin( deg2rad( 2 * $f - $m ) ) - 0.0006 * sin( deg2rad( 2 * $f + $mprime ) ) + 0.0010 * sin( deg2rad( 2 * $f - $mprime ) ) + 0.0005 * sin( deg2rad( $m + 2 * $mprime ) ); $apcor = true; } else if ( abs( $phase - 0.25 ) < 0.01 || abs( $phase - 0.75 ) < 0.01 ) { $pt += (0.1721 - 0.0004 * $t) * sin( deg2rad( $m ) ) + 0.0021 * sin( deg2rad( 2 * $m ) ) - 0.6280 * sin( deg2rad( $mprime ) ) + 0.0089 * sin( deg2rad( 2 * $mprime) ) - 0.0004 * sin( deg2rad( 3 * $mprime ) ) + 0.0079 * sin( deg2rad( 2 * $f ) ) - 0.0119 * sin( deg2rad( $m + $mprime ) ) - 0.0047 * sin( deg2rad ( $m - $mprime ) ) + 0.0003 * sin( deg2rad( 2 * $f + $m ) ) - 0.0004 * sin( deg2rad( 2 * $f - $m ) ) - 0.0006 * sin( deg2rad( 2 * $f + $mprime ) ) + 0.0021 * sin( deg2rad( 2 * $f - $mprime ) ) + 0.0003 * sin( deg2rad( $m + 2 * $mprime ) ) + 0.0004 * sin( deg2rad( $m - 2 * $mprime ) ) - 0.0003 * sin( deg2rad( 2 * $m + $mprime ) ); if ( $phase < 0.5 ) // First quarter correction $pt += 0.0028 - 0.0004 * cos( deg2rad( $m ) ) + 0.0003 * cos( deg2rad( $mprime ) ); else // Last quarter correction $pt += -0.0028 + 0.0004 * cos( deg2rad( $m ) ) - 0.0003 * cos( deg2rad( $mprime ) ); $apcor = true; } if (!$apcor) // function was called with an invalid phase selector return false; return $pt; } /* Find time of phases of the moon which surround the current date. Five phases are found, starting and ending with the new moons which bound the current lunation. */ private function phasehunt() { $sdate = $this->utctojulian( $this->timestamp ); $adate = $sdate - 45; $ats = $this->timestamp - 86400 * 45; $yy = (int) gmdate( 'Y', $ats ); $mm = (int) gmdate( 'n', $ats ); $k1 = floor( ( $yy + ( ( $mm - 1 ) * ( 1 / 12 ) ) - 1900 ) * 12.3685 ); $adate = $nt1 = $this->meanphase( $adate, $k1 ); while (true) { $adate += $this->synmonth; $k2 = $k1 + 1; $nt2 = $this->meanphase( $adate, $k2 ); // if nt2 is close to sdate, then mean phase isn't good enough, we have to be more accurate if( abs( $nt2 - $sdate ) < 0.5 ) $nt2 = $this->truephase( $k2, 0.0 ); if ( $nt1 <= $sdate && $nt2 > $sdate ) break; $nt1 = $nt2; $k1 = $k2; } // results in Julian dates $data = array( $this->truephase( $k1, 0.0 ), $this->truephase( $k1, 0.25 ), $this->truephase( $k1, 0.5 ), $this->truephase( $k1, 0.75 ), $this->truephase( $k2, 0.0 ) ); $this->quarters = array(); foreach( $data as $v ) $this->quarters[] = ( $v - 2440587.5 ) * 86400; // convert to UNIX time } /* Convert UNIX timestamp to astronomical Julian time (i.e. Julian date plus day fraction). */ private function utctojulian( $ts ) { return $ts / 86400 + 2440587.5; } private function get_phase( $n ) { if( is_null( $this->quarters ) ) $this->phasehunt(); return $this->quarters[$n]; } /* Public functions for accessing results */ function phase(){ return $this->phase; } function illumination(){ return $this->illum; } function age(){ return $this->age; } function distance(){ return $this->dist; } function diameter(){ return $this->angdia; } function sundistance(){ return $this->sundist; } function sundiameter(){ return $this->sunangdia; } function new_moon(){ return $this->get_phase( 0 ); } function first_quarter(){ return $this->get_phase( 1 ); } function full_moon(){ return $this->get_phase( 2 ); } function last_quarter(){ return $this->get_phase( 3 ); } function next_new_moon(){ return $this->get_phase( 4 ); } } ?> moon.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include("moon-phase.php"); define('SIZECONST', 0.541169); $size = isset($_GET['size']) ? $_GET['size'] : 200; $date = isset($_GET['date']) ? strtotime($_GET['date']) : time(); $moon = new MoonPhase($date); $phase = $moon->phase(); $illum = $moon->illumination(); $diam = round($moon->diameter(), 6); $r = $size/SIZECONST; $scaled = 2*$r*sin($diam/2); $pcent = 1 - $illum; $waxing = $phase < 0.5; $im = imagecreatetruecolor($size,$size); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 0xF7, 0xF7, 0xF7); $cx = $cy = imagesx($im)/2; $r = $scaled/2; imageantialias($im, 1); imagefill($im, 0, 0, $black); imagefilledellipse($im, $cx, $cy, 2*$r, 2*$r, $white); imageellipse($im, $cx, $cy, 2*$r, 2*$r, $black); imagecolortransparent($im, $black); imagesetthickness($im, 2); for ($y = $cy-$r; $y <= $cy+$r; $y++) { $theta = asin(($cy-$y)/$r); if ($waxing) { $x1 = $cx - $r*cos($theta); $x2 = $x1 + 2 * $pcent * $r * cos($theta); } else { $x2 = $cx + 2 + $r*cos($theta); $x1 = $x2 - 2 * $pcent * $r * cos($theta)-1; } imageline($im, $x1, $y, $x2, $y, $black); } header("content-type: image/png"); imagepng($im); imagedestroy($im); ?> <img src='moon.php?size=100&date=<?php echo date("Y/m/d"); ?>' /> </body> </html> URL: https://tornhq.com/Top_Menu/moon.php Result: Unable to show, not allowed to use the image extension here.
  19. I updated my code with the one you have provided, of which still does not work; https://tornhq.com/Top_Menu/moonphrase.php my code: <?php $month = isset($_GET['month']) ? $_GET['month'] : date('m'); $start = date('Y-m-d', mktime(0,0,0,$month,1)); $end = date('Y-m-t', strtotime($start)); $s = new DateTime($start); $e = new DateTime($end); $e->modify('+1 days'); $inc = new DateInterval('P1D'); $dp = new DatePeriod($s, $inc, $e); $out = ''; foreach ($dp as $d) { $out .= "<span style='color:#FFF'>" . $d->format('j') . "</span>"; $out .= "<img src='moon.php?date={$d->format('Y-m-d')}&size=100' />\n"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta name="author" content="Barand"> <meta name="generator" content="PhpED 8.1"> <meta name="description" content="moon phases"> <meta name="keywords" content="moon phases"> <meta name="creation-date" content="03/16/2013"> <title>Moon</title> </head> <body> <?php echo '<h3>' . $s->format('F Y') . " Moon Phases</h3>\n"?> <div id='wrapper' style="width: 780px; background-color: #142FAD;"> <?php echo $out?> </div> </body> </html> As for the attached file, I am having no luck there to, I am not sure if I have meant to include anything for either. Am I meant to have an image of the moon somewhere, I have had it in my head that this actually somehow creates an image? https://tornhq.com/Top_Menu/moonphrase2.php Best Regards, Tim
  20. How do I make my current code function dynamically as I notice upon each refresh the distance from the Earth to the Moon changes?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.