Search:

Return to previous page

Contents of file 'dailyquote.php':




Deprecated: Function split() is deprecated in /storage/content/45/2011745/jonsson.eu/public_html/php/htmlicise.php on line 46
    1   <?php
    2   //============================================================================
    3   // File:        dailyquote.php [PHP script]
    4   // Created:     August 20, 2006 [v.1.0]
    5   // Last change: January 23, 2014 [v.1.24]
    6   // Author:      Fredrik Jonsson <http://jonsson.eu/>
    7   //
    8   // DESCRIPTION
    9   //  The DAILYQUOTE script generates (X)HTML code for displaying quotes
   10   //  handpicked from the literature, films, newspapers or other sources.
   11   //  The DAILYQUOTE script forms the server-side engine for the automatic
   12   //  generation of daily quotes found at the entry page of jonsson.eu.
   13   //
   14   //  Copyright (C) 2006-2008, Fredrik Jonsson <http://jonsson.eu/>
   15   //  Non-commercial copying welcome.
   16   //============================================================================
   17   //
   18   // ###########################################################################
   19   // ######## CUSTOMIZE THE FOLLOWING PARAMETERS WITH YOUR OWN SETTINGS ########
   20   // ###########################################################################
   21   //
   22   // If you have a particular, own-defined quote to display, then simply set
   23   // $test_quote equal to the particular quote number; otherwise set to zero
   24   //
   25   $test_quote=0;
   26   //
   27   // ###########################################################################
   28   // ######## END OF USER CUSTOMIZABLE PARAMETERS ##############################
   29   // ###########################################################################
   30   //
   31   
   32   //----------------------------------------
   33   $quote[1]="Det &auml;r bara att bryta ihop och g&aring; vidare.";
   34   $source[1]="<a href=\"http://en.wikipedia.org/wiki/Torgny_Mogren\">Torgny
   35     Mogren,</a> Swedish cross-country skier (Four World Championship gold
   36     medals 1987-93 and an Olympic gold medal 1988)";
   37   
   38   //----------------------------------------
   39   $quote[2]="The work of science is to substitute facts for appearances, and
   40     demonstrations for impressions.";
   41   $source[2]="John Ruskin, The stones of Venice (1853).";
   42   
   43   //----------------------------------------
   44   $quote[3]="Aren't we forgeting the true meaning of Christmas? You know, the
   45     birth of Santa.";
   46   $source[3]="Bart Simpson.";
   47   
   48   //----------------------------------------
   49   $quote[4]="Science is knowledge that we understand so well that we can teach
   50   it to a computer; and if we don't fully understand something, it is an art to
   51   deal with.";
   52   $source[4]="Donald E. Knuth, Computer Programming as an Art (A. M. Turing Award
   53   Lecture, 1974).";
   54   
   55   //----------------------------------------
   56   $quote[5]="To my mind, the book is better than ever. May each reader benefit
   57     and enjoy!";
   58   $source[5]="J.D. Jackson, in his own modest preface to the second edition of
   59     his Classical Electrodynamics (Wiley, 1974).";
   60   
   61   //----------------------------------------
   62   $quote[6]="At your fingertips you have a tool that was unavailable to
   63     Archimedes, Galileo, or Einstein. The only limits to the flexibility of
   64     the HP-25 are the limits of your own mind.";
   65   $source[6]="<a href=\"http://www.hpmuseum.org/hp25.htm\">Hewlett-Packard 25</a>
   66     Handbook (1975)";
   67   
   68   //----------------------------------------
   69   $quote[7]="Professor Goddard does not know the relation between action and
   70     reaction and the need to have something better than a vacuum against which
   71     to react. He seems  to lack the basic knowledge ladled out daily in high
   72     schools.";
   73   $source[7]="1921 New York Times editorial about Robert Goddard's revolutionary
   74     rocket work.";
   75   $followup_quote[7]="Correction: It is now definitely established that a rocket
   76     can function in a vaccuum. The Times regrets the error.";
   77   $followup_source[7]="New York Times, July 1969.";
   78   
   79   //----------------------------------------
   80   $quote[8]="I'm Winston Wolfe. I solve problems.";
   81   $source[8]="Pulp Fiction (Quentin Tarantino, 1994)";
   82   
   83   //----------------------------------------
   84   $quote[9]="But the science is always there,<br/>I'd be a true sucker<br/>if I
   85     acted like I didn't care.";
   86   $source[9]="<a href=\"http://en.wikipedia.org/wiki/Ice-T\">Ice-T</a> (Original
   87     Gangster, Sire Records, 1991)";
   88   
   89   //----------------------------------------
   90   $quote[10]="Marge, it takes two to lie. One to lie and one to listen.";
   91   $source[10]="<a href=\"http://en.wikipedia.org/wiki/Homer_Simpson\">Homer
   92     Simpson</a>";
   93   
   94   //----------------------------------------
   95   $quote[11]="<tt>/* vsprintf.c -- Lars Wirzenius &amp; Linus Torvalds. */<br/>
   96     /* Wirzenius wrote this portably, Torvalds fucked it up :-) */</tt>";
   97   $source[11]="Extract from the C-code of the historic first-ever release of
   98     the Linux kernel (Linus Torvalds, <a href=\"http://www.funet.fi\">
   99     funic.funet.fi</a>, August 1991)";
  100   
  101   //----------------------------------------
  102   $quote[12]="Oh Lisa, there's no such thing as vampires. They're make-believe,
  103     like fairies, goblins and Eskimos.";
  104   $source[12]="<a href=\"http://en.wikipedia.org/wiki/Homer_Simpson\">Homer
  105     Simpson</a>";
  106   
  107   //----------------------------------------
  108   $quote[13]="The path of the righteous man is beset on all sides by the
  109     inequities of the selfish and the tyranny of evil men. Blessed is he
  110     who, in the name of charity and good will, shepherds the weak through
  111     the valley of darkness, for he is truly his brother's keeper and the
  112     finder of lost children. And I will strike down upon thee with great
  113     vengeance and furious anger those who attempt to poison and destroy my
  114     brothers. And you will know my name is the Lord when I lay my vengeance
  115     upon you.";
  116   $source[13]="Pulp Fiction, Ezekiel 25:17 (Quentin Tarantino, 1994)";
  117   
  118   //----------------------------------------
  119   $quote[14]="If one does not know to which port one is sailing, no wind is
  120     favorable.";
  121   $source[14]="Seneca (5 BC-65 AD), Roman dramatist, philosopher and politician";
  122   
  123   //----------------------------------------
  124   $quote[15]="Everything is vague to a degree you do not realize till you have
  125     tried to make it precise.";
  126   $source[15]="<a href=\"http://en.wikipedia.org/wiki/Bertrand_Russell\">Bertrand
  127     Russell</a> (1872-1970)";
  128   
  129   //----------------------------------------
  130   $quote[16]="So far as I can remember, there is not one word in the Gospels in
  131     praise of intelligence.";
  132   $source[16]="<a href=\"http://en.wikipedia.org/wiki/Bertrand_Russell\">Bertrand
  133     Russell</a> (1872-1970)";
  134   
  135   //----------------------------------------
  136   $quote[17]="Completely sugar free.";
  137   $source[17]="The British toothpaste \"Milk teeth fluoride plus\", manufactured
  138     by GlaxoSmithKline (2007)";
  139   
  140   //----------------------------------------
  141   $quote[18]="H&auml;r ligger en gravad hund.";
  142   $source[18]="<a href=\"http://susning.nu/Refaat_El-Sayed\">Refaat
  143     El-Sayed</a>";
  144   
  145   //----------------------------------------
  146   $quote[19]="Om man har lite skulder &auml;r det som en kulle, men om man har
  147     mycket skulder blir det som ett berg d&auml;r man kan g&aring; upp och
  148     titta lite p&aring; utsikten.";
  149   $source[19]="<a href=\"http://susning.nu/Refaat_El-Sayed\">Refaat
  150     El-Sayed</a>";
  151   
  152   //----------------------------------------
  153   $quote[20]="That which is not measurable is not science. That which is not
  154     Physics is stamp collecting.";
  155   $source[20]="<a href=\"http://en.wikipedia.org/wiki/Ernest_Rutherford\">Ernest
  156     Rutherford</a> (1871-1937)";
  157   
  158   //----------------------------------------
  159   $quote[21]="Not only is the universe stranger than we imagine, it is stranger
  160     than we <em>can</em> imagine.";
  161   $source[21]="Sir
  162     <a href=\"http://en.wikipedia.org/wiki/Arthur_Stanley_Eddington\">Arthur
  163     Eddington</a> (1882-1944)";
  164   
  165   //----------------------------------------
  166   $quote[22]="I do not fear computers. I fear the lack of them.";
  167   $source[22]="<a href=\"http://en.wikipedia.org/wiki/Isaac_Asimov\">Isaac
  168     Asimov</a> (1920-1992)";
  169   
  170   //----------------------------------------
  171   $quote[23]="There is no reason for any individual to have a computer in his
  172     home.";
  173   $source[23]="Ken Olsen (1926-), President,
  174     <a href=\"http://en.wikipedia.org/wiki/Digital_Equipment_Corporation\">
  175     Digital Equipment,</a> 1977";
  176   
  177   //----------------------------------------
  178   $quote[24]="Computers are useless. They can only give you answers.";
  179   $source[24]="<a href=\"http://en.wikipedia.org/wiki/Pablo_Picasso\">Pablo
  180     Picasso</a> (1881-1973)";
  181   
  182   //----------------------------------------
  183   $quote[25]="Where a calculator on the ENIAC is equipped with 18,000 vacuum
  184     tubes and weighs 30 tons, computers in the future may have only 1,000
  185     vaccuum tubes and perhaps weigh 1.5 tons.";
  186   $source[25]="Unknown,
  187     <a href=\"http://en.wikipedia.org/wiki/Popular_Mechanics\">Popular
  188     Mechanics</a>, March 1949";
  189   
  190   //----------------------------------------
  191   $quote[26]="I'm still an atheist, thank God.";
  192   $source[26]="<a href=\"http://www.imdb.com/name/nm0000320/\">Luis
  193     Bu&#241;uel</a> (1900-1983)";
  194   
  195   //----------------------------------------
  196   $quote[27]="We don't have the money, so we have to think.";
  197   $source[27]="Sir
  198     <a href=\"http://en.wikipedia.org/wiki/Arthur_Stanley_Eddington\">Arthur
  199     Eddington</a> (1882-1944)";
  200   
  201   //----------------------------------------
  202   $quote[28]="Eh? Some don't want take it personal? Unu talk bout don, you think
  203     me come fi don.";
  204   $source[28]="<a href=\"http://en.wikipedia.org/wiki/Cutty_Ranks\">Cutty_Ranks
  205     </a> (Limb by Limb, Suburban Base Records, 1995)";
  206   
  207   //----------------------------------------
  208   $quote[29]="Don't panic.";
  209   $source[29]="<a href=\"http://en.wikipedia.org/wiki/Douglas_Adams\">Douglas
  210     Adams</a> (1952-2001), The Hitchhikers Guide to the Galaxy";
  211   
  212   //----------------------------------------
  213   $quote[30]="D&auml;r ser du: din vetenskap och teknik, vad &auml;r det
  214     j&auml;mf&ouml;rt med magi och trolldom?";
  215   $source[30]="Skrot-Nisse och hans v&auml;nner
  216     (<a href=\"http://en.wikipedia.org/wiki/Jan_L&ouml;&ouml;f\">Jan
  217     L&ouml;&ouml;f</a>, Sveriges Television, 1985)";
  218   
  219   //----------------------------------------
  220   $quote[31]="I would never die for my beliefs because I might be wrong.";
  221   $source[31]="<a href=\"http://en.wikipedia.org/wiki/Bertrand_Russell\">Bertrand
  222     Russell</a> (1872-1970)";
  223   
  224   //----------------------------------------
  225   $quote[32]="&Auml;t dina fiskpinnar. I morron &auml;r du r&ouml;kt.";
  226   $source[32]="<a
  227     href=\"http://sv.wikipedia.org/wiki/Super_Mario_L&aring;ngben\">Super Mario
  228     L&aring;ngben</a> (Simonize and Woodgrove, 2007)";
  229   
  230   //----------------------------------------
  231   $quote[33]="That's one small step for man, one giant leap for mankind.";
  232   $source[33]="The first words spoken on the moon (Neil Armstrong, July 21,
  233     1969)";
  234   $followup_quote[33]="Let's get this motherfucker out of here!";
  235   $followup_source[33]="The <em>last</em> words spoken on the moon (Eugene
  236     Cernan, December 14, 1972)";
  237   
  238   //----------------------------------------
  239   $quote[34]="Well there's diamonds on my windshield and these tears from heaven
  240     well i'm pulling into town on the interstate i got a steel train in the rain
  241     and the wind bites my cheek through the wing and it's these late nights and
  242     this freeway flying that always makes me sing, it always makes me sing.";
  243   $source[34]="Tom Waits (Asylum Years, Warner Records, 1986)";
  244   
  245   //----------------------------------------
  246   $quote[35]="Everything should be made as simple as possible, but not simpler.";
  247   $source[35]="<a href=\"http://en.wikipedia.org/wiki/Albert_Einstein\">Albert
  248     Einstein</a>";
  249   
  250   // $followup_quote[35]="It can scarcely be denied that the supreme goal of all
  251   //   theory is to make the irreducible basic elements as simple and as few as
  252   //   possible without having to surrender the adequate representation of a
  253   //   single datum of experience.";
  254   // $followup_source[35]="<a
  255   //   href=\"http://en.wikipedia.org/wiki/Albert_Einstein\">Albert Einstein</a>,
  256   //   <em>On the Method of Theoretical Physics</em> Herbert Spencer Lecture
  257   //   delivered at Oxford (10 June 1933); Phil. Sci., <b>1</b>, 163 (1934).";
  258   
  259   //----------------------------------------
  260   $quote[36]="It is a mistake to think you can solve any  major  problems  just
  261     with potatoes.";
  262   $source[36]="<a href=\"http://en.wikipedia.org/wiki/Douglas_Adams\">Douglas
  263     Adams</a> (1952-2001), Life, the Universe and Everything";
  264   
  265   //----------------------------------------
  266   $quote[37]="Premature optimization is the root of all evil.";
  267   $source[37]="<a href=\"http://en.wikipedia.org/wiki/Donald_Knuth\">Donald E.
  268     Knuth</a>.";
  269   
  270   //----------------------------------------
  271   $quote[38]="Dwee, dah dah shrah, plah plah sah, dah dah rah, plav da shree,
  272     loh ku pah, dav du sah! Soo-da-li dwee-daht, soo-da-li doo-ton plah-blah.";
  273   $source[38]="<a href=\"http://www.shooby.com/\">William Shooby Taylor</a>
  274     (1929-2003), <a href=\"http://jonsson.eu/programs/php/dailyquote/shooby03.mp3\">
  275     <em>Stout-hearted men</em></a>.";
  276   
  277   //----------------------------------------
  278   $quote[39]="Think outside the box, collapse the box, and take a fucking sharp
  279     knife to it.";
  280   $source[39]="<a href=\"http://www.banksy.co.uk/\">Banksy</a>";
  281   
  282   //----------------------------------------
  283   $quote[40]="I am so smart, S-M-R-T!";
  284   $source[40]="<a href=\"http://en.wikipedia.org/wiki/Homer_Simpson\">Homer
  285     Simpson</a>, in
  286     <a href=\"http://en.wikipedia.org/wiki/Homer_Goes_to_College\">Homer Goes
  287     to College</a>";
  288   
  289   //----------------------------------------
  290   $quote[41]="Pojkar vill, killar kan!";
  291   $source[41]="Brandchef Greger Hawkwind, <a href=\"http://sv.wikipedia.org/wiki/NileCity_105,6\">NileCity 105,6</a>.";
  292   
  293   //----------------------------------------
  294   $quote[42]="$665.95 - Retail price of the Beast";
  295   $source[42]="Joke at 1740 Internet sites, as of March 2009.";
  296   
  297   //----------------------------------------
  298   $quote[43]="Jazz is not dead, it just smells funny";
  299   $source[43]="<a href=\"http://en.wikipedia.org/wiki/Frank_Zappa\">Frank
  300     Zappa</a>";
  301   
  302   //----------------------------------------
  303   $quote[44]="No-one would remember the Good Samaritan if he'd only had good
  304     intentions; he had money as well.";
  305   $source[44]="<a href=\"http://en.wikipedia.org/wiki/Margaret_Thatcher\">
  306     Margaret Thatcher</a>";
  307   
  308   //----------------------------------------
  309   $quote[45]="Jag ger fullst&auml;ndigt fan i vad folk tycker, bara de tycker
  310     n&aring;gonting.";
  311   $source[45]="<a href=\"http://siri.derkert.com\">Siri Derkert</a>";
  312   
  313   //----------------------------------------
  314   $quote[46]="Any sufficiently advanced technology is indistinguishable from
  315     magic.";
  316   $source[46]="<a href=\"http://www.arthurcclarke.net\">Arthur C. Clarke</a>";
  317   
  318   //----------------------------------------
  319   $quote[47]="Ett v&auml;l utf&ouml;rt arbete ger en inre tillfredst&auml;llelse och &auml;r den grund p&aring; vilket samh&auml;llet vilar.";
  320   $source[47]="<a href=\"http://sv.wikipedia.org/wiki/Sagan_om_Karl-Bertil_Jonssons_julafton\">Karl-Bertil Jonsson</a>";
  321   
  322   //----------------------------------------
  323   $quote[48]="Luck is what happens when preparation meets opportunity.";
  324   $source[48]="Seneca (5 BC-65 AD), Roman dramatist, philosopher and politician";
  325   
  326   //----------------------------------------
  327   $quote[49]="Parity is for farmers.";
  328   $source[49]="<a href=\"http://en.wikipedia.org/wiki/Seymour_Cray\">Seymour
  329     Cray</a> (1925-1996), Supercomputer architect and founder of
  330     <a href=\"http://en.wikipedia.org/wiki/Cray_Research\">Cray Research</a>,
  331     on <a href=\"http://en.wikipedia.org/wiki/Cyclic_redundancy_check\">cyclic
  332     redundancy checks</a>.";
  333   
  334   //----------------------------------------
  335   $quote[50]="Comfort diminishes activity; lack of activity leads to lack of
  336      stimulation, without stimulation you become bored, fat and tired. You get
  337      energetic only by using energy, not by resting";
  338   $source[50]="<a href=\"http://www.yrvind.com\">Sven Yrvind</a>, small-boat
  339      world circumnavigator and 1980 Royal Cruising Club medalist for seamanship.";
  340   
  341   function random_daily_integer($min,$max) {
  342     // srand ((double) microtime( )*1000000); // Seeding with ms since 1 Jan 1970
  343     srand ((double) date("j")); // Seeding with the date of the month
  344     return rand($min,$max);
  345   }
  346   
  347   function singlequote($lang,$qindx,$comment_on_quote) {
  348     switch ($lang) {
  349       case en:
  350         $titlestring="Quote of the day";
  351         break;
  352       case sv:
  353         $titlestring="Dagens citat";
  354         break;
  355       default:
  356         $titlestring="";
  357         echo "PHP Error: singlequote(): Language switch \"".$lang.
  358              "\" is not recognized!\n";
  359     }
  360     echo "<div class=\"links\">\n";
  361     echo "<!-- ".$comment_on_quote." -->\n";
  362     echo "<h2>".$titlestring."</h2>\n";
  363     echo "<p class=\"dailyquote\">\n";
  364     echo "  <span class=\"quote\">\"".
  365       $GLOBALS['quote'][$qindx]."\"</span><br/>\n";
  366     echo "  <span class=\"source\"><em>&nbsp;&ndash;&nbsp;".
  367       $GLOBALS['source'][$qindx]."</em></span>\n";
  368     echo "</p>\n";
  369     if ($GLOBALS['followup_quote'][$qindx]!="") {
  370       echo "<p class=\"dailyquote\">\n";
  371       echo "  <span class=\"quote\">\"".
  372         $GLOBALS['followup_quote'][$qindx]."\"</span><br/>\n";
  373       echo "  <span class=\"source\"><em>&nbsp;&ndash;&nbsp;".
  374         $GLOBALS['followup_source'][$qindx]."</em></span>\n";
  375       echo "</p>\n";
  376     }
  377     echo "<p class=\"dailyquote\">\n";
  378     $dailyquote_url="http://jonsson.eu/programs/php/dailyquote/";
  379     echo "Generated by <a href=\"".$dailyquote_url."\">::dailyquote::</a>\n";
  380     echo "</p>\n";
  381     echo "</div>\n";
  382     return;
  383   }
  384   
  385   function dailyquote($lang,$mode) {
  386     $copyright_notice="Copyright (C) Fredrik Jonsson, 2006-2008";
  387     $test_quote=$GLOBALS['test_quote']; // Non-zero to display particular quote
  388     $num_quotes=sizeof($GLOBALS['quote']); // Number of defined quotes
  389     $num_sources=sizeof($GLOBALS['source']); // Number of defined sources
  390   
  391     //
  392     // First check that we actually have a source defined for each of the
  393     // available quotes.
  394     //
  395     if ($num_quotes!=$num_sources) {
  396       echo "PHP Error in dailyquote():\n";
  397       echo "Number of quotes differ from number of sources!\n";
  398     }
  399     if ($mode=="single") {
  400       //
  401       // Generate a single quote. (The "single" mode.)
  402       //
  403       $comment_on_quote="Quote generated by dailyquote.php; ".$copyright_notice;
  404       if ($test_quote>0) { // If a test of a quote is to be performed, ...
  405         $qindx=$test_quote;
  406         $comment_on_quote="Test quote No ".$test_quote.", ".$copyright_notice;
  407       } else if ($random_quote) { // ... else select a random quote, ...
  408         $qindx=mt_rand(1,$num_quotes);
  409       } else { // ... or simply base the quote number on the day of the month.
  410         //
  411         // The data returned by date("j") is in fact a string; however, the
  412         // loose type definition of PHP takes care of a conversion to an
  413         // integer whenever needed, as for example when the variable is used
  414         // in arithmetics.
  415         //
  416         // $qindx=date("j");
  417         // while ($qindx>$num_quotes)   // Make sure that the index actually is
  418         //  $qindx=$qindx-$num_quotes;  // within range of the array of quotes.
  419         $qindx=random_daily_integer(1,$num_quotes);
  420       }
  421       singlequote($lang,$qindx,$comment_on_quote);
  422       echo "<!-- End of quote automatically generated by dailyquote.php -->\n";
  423     } elseif ($mode=="all") {
  424   
  425       //
  426       // Generate a list of all available quotes. (The "all" mode.)
  427       //
  428       $comment_on_quote="Quotes generated by dailyquote.php; ".$copyright_notice;
  429       echo "<!-- ".$comment_on_quote." -->\n";
  430       // echo "<h2>Quotes available to dailyquote.php</h2>\n";
  431       for ($k=1;$k<=$num_quotes;$k++) {
  432         echo "<h3>Quote number ".$k."</h3>\n";
  433         echo "<p class=\"dailyquote\">\n";
  434         echo "  <span class=\"quote\">\"".
  435           $GLOBALS['quote'][$k]."\"</span><br/>\n";
  436         echo "  <span class=\"source\"><em>&nbsp;&ndash;&nbsp;".
  437           $GLOBALS['source'][$k]."</em></span>\n";
  438         echo "</p>\n";
  439         if ($GLOBALS['followup_quote'][$k]!="") {
  440           echo "<p class=\"dailyquote\">\n";
  441           echo "  <span class=\"quote\">\"".
  442             $GLOBALS['followup_quote'][$k]."\"</span><br/>\n";
  443           echo "  <span class=\"source\"><em>&nbsp;&ndash;&nbsp;".
  444             $GLOBALS['followup_source'][$k]."</em></span>\n";
  445           echo "</p>\n";
  446         }
  447       }
  448       echo "<!-- End of quote automatically generated by dailyquote.php -->\n";
  449     } else {
  450   
  451       //
  452       // If no valid mode was detected, then generate an error message and
  453       // exit from the dailyquote.php script.
  454       //
  455       echo "<!-- Code automatically generated by dailyquote.php -->\n";
  456       echo "PHP Error: Mode \"".$mode."\" is not recognized!\n";
  457       echo "<!-- End of code automatically generated by dailyquote.php -->\n";
  458       exit(1);
  459     }
  460     return;
  461   }
  462   ?>
  463   

Return to previous page

Generated by ::viewsrc::

Last modified Tuesday 28 Dec 2010