<?php 
/** 
 * PHPoem #3
 * The Big Picture
 * 
 * @author  Kasper Skårhøj <kasper@typo3.com> 
 * Freely interpreted from The Holy Bible
 */ 



// *******************************************************
// INITIALIZATION, 6 days:
// In the beginning The Programmer 
// created the heavens and the earth.
// 
// Notice: 
// This initialization is outside the scope of what is 
// possible within the main loop later on. So don't try
// to explain it away by your limited knowledge!
// *******************************************************

// First a series of creation acts. Abbreviated version.
echo "Let there be light\n";    //...and there was light
echo "Let there be an expanse between the waters 
      to separate water from water.\n"
;     // And it was so. 
echo "Let the land produce vegetation: 
      seed-bearing plants and trees on the land 
      that bear fruit with seed in it.\n"
;     // And it was so. 
echo "Let there be lights in the expanse of 
      the sky to separate the day from the night.\n"
;
echo 
"Let the water teem with living creatures, 
      and let birds fly above the earth.\n"
;
echo 
"Let the land produce living creatures 
      according to their kinds.\n"
;     // And it was so. 

// Then to the masterpiece, man and woman:
echo "Let us make man in our image, 
      in our likeness.\n"
;  // So The Programmer created man in his own image!

// $man is passed by reference here.
// "free will" is necessary - but risky - because true love requires it.
implementFreeWill(&$man["Adam"],&$man["Eve"]);    

      
// The Programmer saw all that he had made, and it was very good.
// At this point the initialization is finished
// and The Programmer took a nap:

sleep(1*24*3600);    // The 7th day


// **************************************************
// WARNING:
// An internal, evil-minded process has rebelled here
// and makes the following execution HIGHLY unstable!
// The predicted effects on the environment will be
// like email-viruses in disguise as apparently innocent 
// offers. DON'T ACCEPT SUCH OFFERS!
// **************************************************




// ***************************************************
// MAIN loop, endless: 
//
// This is the originally intended loop of the program.
// Although the actual main loop is done in the exception
// handler this loop represents the true intention of
// The Programmer from the beginning.
// **************************************************
while(1==1) {
    
// Living life to the fullest:
    // This is the perfect, stable state of this application
    // The only requirement is, that any email-virus is NOT opened!
  
liveLifeForever();
  
    
// This would truely be a sad thing, if that happend...:
  
if (virusFromEvilProcessOpened())    {
      
// If this happens, the Evil Process must have succeeded
      // to interfere with the objects inside the main loop
    
break;    
  }
  
    
// The Programmer sustains the creation supernaturally:
  
doMaintenance();





// ***************************************************
// TEMPORARY loop - emergency plan: 
//
// About this state, The Programmer says:
//
// Since you are here, you must have opened the email-
// virus I warned you against!
// Because I did warn you and you were tempted by 
// the Evil Process to open in anyway, I had to break the 
// eternal loop to be consistent with my promise.
//
// However I will initiate an emergency plan, which 
// will eventually clean up the system, kill the virus and 
// reinstate the eternal loop.
// This plan will be revealed in the code below:
// **************************************************


  // ****************************************************************
  // First: This changes the environmental settings to "Curse-state":
  // ****************************************************************
  
  // Maintenance withdrawn.
  // By stopping the automatic maintenance all objects
  // will age by time and finally die out.
  // Previously in the eternal loop, this did not happen.
haltAutomaticMaintenance();    

  
// Make other changes to the initial rules of the system
changePhysicalLawsAsNeeded();

  
// Adapt objects to the new situation:
accommodateObjectsToCurse();

  
// The connection from The Programmer to the loop is severely
  // scrambled as well.
  // Most likely the objects (men) inside the loop will not
  // recognize the existence of the Programmer due to this
  // "lack of proof of existence".
reduceSpiritualSignalToNoiseRatio();



  
// ****************************************************************
  // Second: The new loop is configured:
  // ****************************************************************

  // The actual length of the loop is not known for certain. 
  // It's at least 6000 years, but obviously longer yet, because we're 
  // still within the temporary loop.
$tempLoopLifeSpan=6000;    

  
// Prepare array for instruction. Popularly called "The Bible".
$manual=array();


  
// Temp loop:
for($a=0$a<$tempLoopLifeSpan$a++)    {
  
      
// This executes the living of life under the new
    // limited circumstances of the temporary loop:
  
liveExceptionHandler();
  
    
// This adds instructions to the manual during the loop as needed.
    // This is the ultimate info-booth with authoritative answers
  
if ($a<4000)    {
    
addInstructionsDuringLifeSpan(&$manual);
  }


    
// IMPORTANT break point in the loop:
    // After approximately 4000 loops the secret weapon
    // is revealed here: Jesus Christ
  
if ($a==4000)  {
    
introduceJesusChrist();    // Christ was born
  
}
  if (
$a==4030)  {

       
// The MAIN event is here!
       // Christ was unset at this point by the "man" objects
       // (The actual method called was 'doCrusify("Christ")' ), 
       // but The Programmer intervened and un-did this action!
       // This was indeed an unusual and supernatural thing to do!
       // By doing that The Programmer initiated Christ's status
       // as an abstraction layer that would present a clean
       // interface of any object calling the method
       // acceptChrist() no matter how messy the object was 
       // internally.
       // 
       // The point was, that if the "man" objects is to
       // persist all the way into the future eternal loop, 
       // they must be "clean". However this is not possible 
       // by any inherent methods, so The Programmer introduced
       // the acceptChrist() method by calling resurrectChristFromTheDead()
       // 
       // And after this point in the loop, any "man" object
       // calling acceptChrist() will also exist in the future
       // eternal loop!
       // So easy and ingenious that many has tried to make 
       // it more complicate unfortunately.
       
    
resurrectChristFromTheDead();    

      
// New rules for getting into eternal loop is applied
    
applyNewRules();    
  }
  if (
$a>4030 && $a>4110)    {
      
// This adds description of the new rules for 
      // the rest of the loop:
    
addInstructionsDuringLifeSpan(&$manual);
  }
  
  
}




// ***************************************************
// ETERNAL LOOP reinstated: 
//
// This part of the program is not known yet.
// But I assure you it will be ready in time.
// The only question is how many of the "man" objects 
// that will enter the new loop. This depends on their
// own free will to call the method acceptChrist()
//
// One thing I'm very exited about is to experience the
// original eternal loop running again.
// But I also wonder how The Programmer will manage to
// prevent processes from becoming evil like it happend
// in the first place. That is a mystery
// we will see solved later on.
//
// If anyone wants to know more about the API of the 
// acceptChrist() method, I have a lot of links to good
// resources. Just mail me: kasper@typo3.com
//
// May The Programmer fill your internal $joy-array this Easter!
// - kasper
// 
// **************************************************

?>