com web/php: Replace the index.php with the new layout, dropping the old one: index-beta.php index-stable.php index.php
| From: | Hannes Magnusson | Date: | Thu, 21 Nov 2013 00:11:28 +0000 |
| Subject: | com web/php: Replace the index.php with the new layout, dropping the old one: index-beta.php index-stable.php index.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17104@lists.php.net to get a copy of this message | ||
Commit: ccf9c6399eaeecf7bfa1e2f5008dbff71eeb6a26
Author: Hannes Magnusson <bjori@mongodb.com> Wed, 20 Nov 2013 16:11:28 -0800
Parents: bafcd11c5fd2075408341847563aa5b228f36d73
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=ccf9c6399eaeecf7bfa1e2f5008dbff71eeb6a26
Log:
Replace the index.php with the new layout, dropping the old one
Changed paths:
D index-beta.php
D index-stable.php
M index.php
diff --git a/index-beta.php b/index-beta.php deleted file mode 100644 index 612e869..0000000 --- a/index-beta.php +++ /dev/null @@ -1,191 +0,0 @@ -<?php // vim: et -/* - If you're reading this, it isn't because you've found a security hole. - this is an open source website. read and learn! -*/ - -/* ------------------------------------------------------------------------- */ - -// Get the modification date of this PHP file -$timestamps = array(@getlastmod()); - -/* - The date of prepend.inc represents the age of ALL - included files. Please touch it if you modify any - other include file (and the modification affects - the display of the index page). The cost of stat'ing - them all is prohibitive. Also note the file path, - we aren't using the include path here. -*/ -$timestamps[] = @filemtime("include/prepend.inc"); - -// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page -$timestamps[] = @filemtime("include/pregen-events.inc"); -$timestamps[] = @filemtime("include/pregen-confs.inc"); -$timestamps[] = @filemtime("include/pregen-news.inc"); -$timestamps[] = @filemtime("include/version.inc"); - -// The latest of these modification dates is our real Last-Modified date -$timestamp = max($timestamps); - -// Note that this is not a RFC 822 date (the tz is always GMT) -$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; - -// Check if the client has the same page cached -if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && - ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { - header("HTTP/1.1 304 Not Modified"); - exit(); -} -// Inform the user agent what is our last modification date -else { - header("Last-Modified: " . $tsstring); -} - -$_SERVER['BASE_PAGE'] = 'index.php'; -include_once 'include/prepend.inc'; -include_once 'include/pregen-events.inc'; -include_once 'include/pregen-confs.inc'; -include_once 'include/pregen-news.inc'; -include_once 'include/version.inc'; - -// Prepare announcements. -if (is_array($CONF_TEASER) && $CONF_TEASER) { - $teaser_categories = array( - 'conference' => 'Upcoming conferences', - 'cfp' => 'Calling for papers', - ); - - $announcements = '<ul class="announcements">'; - - foreach ($CONF_TEASER as $category => $events) { - if (is_array($events) && $events) { - $announcements .= '<li><span class="category">'.$teaser_categories[$category].':</span><ul>'; - $links = array(); - foreach (array_slice($events, 0, 4) as $url => $title) { - $title = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $title); - $announcements .= "<li><a href='$url'>$title</a></li>"; - } - $announcements .= '</ul>'; - } - } - - $announcements .= '</ul>'; -} else { - $announcements = ''; -} - - -require_once './Gateway/NewsFileSystemGateway.php'; - -$NewsGateway = new NewsFileSystemGateway(); -$RecentNews = $NewsGateway->getArticlesForCategories(array( - "frontpage" -), 4); - -ob_start(); - -require_once './View/HomepageNewsView.php'; -$RecentNewsView = new HomepageNewsView($RecentNews); - -echo $RecentNewsView->render(); - -$news = ob_get_clean(); - -// Wrap announcements and features in a content element -$content = " -<div class='home-content'> - $news -</div> -"; - -$intro = <<<EOF - <div class="row-fluid"> - <div class="span9 blurb"> - <p>PHP is a popular general-purpose scripting language that is especially suited to web development.</p> - <p>Fast, flexible and pragmatic, PHP powers everything from your blog to the largest social networking site in the world.</p> - </div> - <div class="background span3"></div> - <div class="span3"> - <div class="download-php"> - <h2>Download PHP</h2> - -EOF; -if(!empty($RELEASES[5])) { - $releases = array_chunk($RELEASES[5], 2, $preserve_keys = TRUE); - foreach ($releases as $row) { - $intro .= " - <div class='row-fluid'> -"; - foreach ($row as $version => $release) { - $intro .= " - <div class='span6'> - <p><a class='download-link' href='/downloads.php#v$version'>$version</a></p> - <p class='notes'><a href='/ChangeLog-5.php#$version'>Release Notes</a></p> - </div> -"; - } - $intro .=" - </div> -"; - } -} -$intro .= <<<EOF - </div> - </div> - </div> -EOF; - -// Write out common header -site_header("Hypertext Preprocessor", - array( - 'current' => 'home', - 'headtags' => array( - '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', - '<script type="text/javascript">', - "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", - "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", - '</script>' - ), - 'link' => array( - array( - "rel" => "search", - "type" => "application/opensearchdescription+xml", - "href" => $MYSITE . "phpnetimprovedsearch.src", - "title" => "Add PHP.net search" - ), - array( - "rel" => "alternate", - "type" => "application/atom+xml", - "href" => $MYSITE . "releases/feed.php", - "title" => "PHP Release feed" - ), - - ), - 'css' => array('home.css'), - 'intro' => $intro - ) -); - -// Print body of home page. -echo $content; - -$SIDEBAR = <<< SIDEBAR_DATA - -$announcements - <p class='panel'><a href='/tips.php'>Tips and Tricks</a></p> - <p class='panel'><a href='/conferences/'>Conferences</a></p> - <p class='panel'><a href='/cal.php'>User Group Events</a></p> - <p class='panel'><a href='/thanks.php'>Special Thanks</a></p> - -SIDEBAR_DATA; - -// Print the common footer. -site_footer( - array( - "atom" => "/feed.atom", // Add a link to the feed at the bottom - 'elephpants' => true, - 'sidebar' => $SIDEBAR - ) -); - diff --git a/index-stable.php b/index-stable.php deleted file mode 100644 index 37924ee..0000000 --- a/index-stable.php +++ /dev/null @@ -1,271 +0,0 @@ -<?php // vim: et -/* - If you're reading this, it isn't because you've found a security hole. - this is an open source website. read and learn! -*/ - -/* ------------------------------------------------------------------------- */ - -// Get the modification date of this PHP file -$timestamps = array(@getlastmod()); - -/* - The date of prepend.inc represents the age of ALL - included files. Please touch it if you modify any - other include file (and the modification affects - the display of the index page). The cost of stat'ing - them all is prohibitive. Also note the file path, - we aren't using the include path here. -*/ -$timestamps[] = @filemtime("include/prepend.inc"); - -// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page -$timestamps[] = @filemtime("include/pregen-events.inc"); -$timestamps[] = @filemtime("include/pregen-confs.inc"); -$timestamps[] = @filemtime("include/pregen-news.inc"); -$timestamps[] = @filemtime("include/version.inc"); - -// The latest of these modification dates is our real Last-Modified date -$timestamp = max($timestamps); - -// Note that this is not a RFC 822 date (the tz is always GMT) -$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; - -// Check if the client has the same page cached -if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && - ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { - header("HTTP/1.1 304 Not Modified"); - exit(); -} -// Inform the user agent what is our last modification date -else { - header("Last-Modified: " . $tsstring); -} - -$_SERVER['BASE_PAGE'] = 'index.php'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-events.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-confs.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-news.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/version.inc'; - -// This goes to the left sidebar of the front page -$SIDEBAR_DATA = ' -<h3>What is PHP?</h3> -<p> - <acronym title="recursive acronym for PHP: Hypertext Preprocessor">PHP</acronym> - is a widely-used general-purpose scripting language that is - especially suited for Web development and can be embedded into HTML. - If you are new to PHP and want to get some idea - of how it works, try the <a href="/tut.php">introductory tutorial</a>. - After that, check out the online <a href="/docs.php">manual</a>. -</p> -<p> - Ever wondered how popular PHP is? See the - <a href="/usage.php">Netcraft Survey</a>. -</p> - -<h3><a href="/thanks.php">Thanks To</a></h3> -<ul class="simple"> - <li><a href="http://www.easydns.com/?V=698570efeb62a6e2" title="DNS Hosting provided by easyDNS">easyDNS</a></li> - <li><a href="http://www.directi.com/">Directi</a></li> - <li><a href="http://promote.pair.com/direct.pl?php.net">pair Networks</a></li> - <li><a href="http://www.servercentral.net/">Server Central</a></li> - <li><a href="http://www.hostedsolutions.com/">Hosted Solutions</a></li> - <li><a href="http://www.spry.com/">Spry VPS Hosting</a></li> - <li><a href="http://www.osuosl.org">OSU Open Source Lab</a></li> - <li><a href="http://www.yahoo.com/">Yahoo! Inc.</a></li> - <li><a href="http://www.nexcess.net/">NEXCESS.NET</a></li> - <li><a href="http://www.rackspace.com/">Rackspace</a></li> - <li><a href="http://www.eukhost.com/">EUKhost</a></li> - <li><a href="http://www.sohosted.nl/webhosting/">SoHosted Webhosting</a></li> - <li><a href="http://www.redpill-linpro.com">Redpill Linpro</a></li> - <li><a href="http://www.facebook.com">Facebook</a></li> - <li><a href="http://krystal.co.uk">Krystal.co.uk</a></li> - <li><a href="http://servergrove.com/">ServerGrove</a></li> - <li><a href="http://www.bauer-kirch.de/">Bauer + Kirch GmbH</a></li> -</ul> -<h3>Related sites</h3> -<ul class="simple"> - <li><a href="http://www.apache.org/">Apache</a></li> - <li><a href="http://www.mysql.com/">MySQL</a></li> - <li><a href="http://www.postgresql.org/">PostgreSQL</a></li> - <li><a href="http://www.zend.com/">Zend Technologies</a></li> -</ul> -<h3>Community</h3> -<ul class="simple"> - <li><a href="http://www.linuxfund.org/">LinuxFund.org</a></li> - <li><a href="http://ostg.com/">OSTG</a></li> -</ul> - -<h3>Syndication</h3> -<p> - You can grab our news as an <a href="/feed.atom">Atom feed</a>. -</p>'; - -$MIRROR_IMAGE = ''; - -// Try to find a sponsor image in case this is an official mirror -if (is_official_mirror()) { - - // Iterate through possible mirror provider logo types in priority order - $types = array("gif", "jpg", "png"); - while (list(,$ext) = each($types)) { - - // Check if file exists for this type - if (file_exists("backend/mirror." . $ext)) { - - // Add text to rigth sidebar - $MIRROR_IMAGE = "<div align=\"center\"><h3>This mirror sponsored by:</h3>\n"; - - // Create image HTML code - $img = make_image( - 'mirror.' . $ext, - htmlspecialchars(mirror_provider()), - FALSE, - FALSE, - 'backend', - 0 - ); - - // Add size information depending on mirror type - if (is_primary_site() || is_backup_primary()) { - $img = resize_image($img, 125, 125); - } else { - $img = resize_image($img, 120, 60); - } - - // End mirror specific part - $MIRROR_IMAGE .= '<a href="' . mirror_provider_url() . '">' . - $img . "</a></div><br /><hr />\n"; - - // We have found an image - break; - } - } -} - -/* {{{ Generate latest release info */ -/* NOTE: You are editing the wrong file, you should be in include/version.inc - * For RC: See the $PHP_x_RC variable - * For STABLE: See the $PHP_x_VERSION/_DATE/_MD5 variables - */ -$PHP_5_STABLE = array(); -$PHP_5_RC = array(); -$rel = $rc = ""; - -$SHOW_COUNT = 3; -for ($i=1; $i<=$SHOW_COUNT; ++$i) { -list($PHP_5_STABLE, ) = each($RELEASES[5]); - -$minor = round($PHP_5_STABLE, 1); -$rel .= <<< EOT - <li class="php5"><a href="/downloads.php#v5">Current PHP $minor Stable: <span class="release">$PHP_5_STABLE</span></a></li> -EOT; -} - -/* Do we have any release candidates to brag about? */ -$RCS = array( - $PHP_5_5_RC => $PHP_5_5_RC_DATE, - $PHP_5_4_RC => $PHP_5_4_RC_DATE, - $PHP_5_3_RC => $PHP_5_3_RC_DATE, -); -if (isset($RCS)) { - foreach ((array)$RCS as $r => $d) { - if ($r) { - $rc .= ' <li class="php5"><a href="http://qa.php.net/"><span class="release">' . "$r ($d)</span></a></li>\n"; - } - } -} - -$rel = <<< EOT - <div id="releaseBox"> - <h4>Stable Releases</h4> - <ol id="releases"> - $rel - </ol> - </div>\n -EOT; - -if (!empty($rc)) { - $rel .= <<< EOT - <div id="candidateBox"> - <h4><a href="http://qa.php.net/rc.php">Release Candidates</a></h4> - <ol id="candidates"> -$rc - </ol> - </div>\n -EOT; -} -/* }}} */ - -// Prepend mirror image & latest releases to sidebar text -$RSIDEBAR_DATA = $MIRROR_IMAGE . $rel . $RSIDEBAR_DATA; - -// Write out common header -site_header("Hypertext Preprocessor", - array( - 'current' => 'home', - 'onload' => 'boldEvents();', - 'headtags' => array( - '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', - '<script type="text/javascript">', - "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", - "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", - '</script>' - ), - 'link' => array( - array( - "rel" => "search", - "type" => "application/opensearchdescription+xml", - "href" => $MYSITE . "phpnetimprovedsearch.src", - "title" => "Add PHP.net search" - ), - array( - "rel" => "alternate", - "type" => "application/atom+xml", - "href" => $MYSITE . "releases/feed.php", - "title" => "PHP Release feed" - ), - - ), - ) -); - -if (is_array($CONF_TEASER) && count($CONF_TEASER)) { - $categories = array("conference" => "Upcoming conferences", "cfp" => "Calling for papers"); - echo ' <div id="confTeaser">' . "\n"; - echo " <table>\n"; - foreach($CONF_TEASER as $k => $a) { - if (is_array($a) && count($a)) { - echo " <tr>\n <td valign='top' style='white-space: nowrap'>".$categories[$k].":</td>\n"; - echo " <td valign='top'>\n"; - echo ' <ul class="' .$k. '">' . "\n"; - $count = 0; - $a = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $a); - foreach($a as $url => $title) { - if ($count++ >= 4) { - break; - } - echo ' <li><a href="' . $url. '">' . $title. '</a></li>' . "\n"; - } - echo " </ul>\n </td>\n </tr>\n"; - } // if set - } - echo " </table>\n </div>\n\n<br />\n"; -} - - -/* Where the h*ll did all the news go? - * See archives/2007.xml - */ -print_news($NEWS_ENTRIES, "frontpage"); -?> - -<p class="center"><a href="/archive/index.php">News Archive</a></p> - -<?php -site_footer( - array("atom" => "/feed.atom") // Add a link to the feed at the bottom -); - diff --git a/index.php b/index.php index fc4c55a..612e869 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,191 @@ <?php // vim: et +/* + If you're reading this, it isn't because you've found a security hole. + this is an open source website. read and learn! +*/ -// show beta home page if user has requested the beta site. -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; -if (myphpnet_beta()) { - include $_SERVER['DOCUMENT_ROOT'] . '/index-beta.php'; +/* ------------------------------------------------------------------------- */ + +// Get the modification date of this PHP file +$timestamps = array(@getlastmod()); + +/* + The date of prepend.inc represents the age of ALL + included files. Please touch it if you modify any + other include file (and the modification affects + the display of the index page). The cost of stat'ing + them all is prohibitive. Also note the file path, + we aren't using the include path here. +*/ +$timestamps[] = @filemtime("include/prepend.inc"); + +// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page +$timestamps[] = @filemtime("include/pregen-events.inc"); +$timestamps[] = @filemtime("include/pregen-confs.inc"); +$timestamps[] = @filemtime("include/pregen-news.inc"); +$timestamps[] = @filemtime("include/version.inc"); + +// The latest of these modification dates is our real Last-Modified date +$timestamp = max($timestamps); + +// Note that this is not a RFC 822 date (the tz is always GMT) +$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; + +// Check if the client has the same page cached +if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && + ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { + header("HTTP/1.1 304 Not Modified"); + exit(); +} +// Inform the user agent what is our last modification date +else { + header("Last-Modified: " . $tsstring); +} + +$_SERVER['BASE_PAGE'] = 'index.php'; +include_once 'include/prepend.inc'; +include_once 'include/pregen-events.inc'; +include_once 'include/pregen-confs.inc'; +include_once 'include/pregen-news.inc'; +include_once 'include/version.inc'; + +// Prepare announcements. +if (is_array($CONF_TEASER) && $CONF_TEASER) { + $teaser_categories = array( + 'conference' => 'Upcoming conferences', + 'cfp' => 'Calling for papers', + ); + + $announcements = '<ul class="announcements">'; + + foreach ($CONF_TEASER as $category => $events) { + if (is_array($events) && $events) { + $announcements .= '<li><span class="category">'.$teaser_categories[$category].':</span><ul>'; + $links = array(); + foreach (array_slice($events, 0, 4) as $url => $title) { + $title = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $title); + $announcements .= "<li><a href='$url'>$title</a></li>"; + } + $announcements .= '</ul>'; + } + } + + $announcements .= '</ul>'; } else { - include $_SERVER['DOCUMENT_ROOT'] . '/index-stable.php'; + $announcements = ''; +} + + +require_once './Gateway/NewsFileSystemGateway.php'; + +$NewsGateway = new NewsFileSystemGateway(); +$RecentNews = $NewsGateway->getArticlesForCategories(array( + "frontpage" +), 4); + +ob_start(); + +require_once './View/HomepageNewsView.php'; +$RecentNewsView = new HomepageNewsView($RecentNews); + +echo $RecentNewsView->render(); + +$news = ob_get_clean(); + +// Wrap announcements and features in a content element +$content = " +<div class='home-content'> + $news +</div> +"; + +$intro = <<<EOF + <div class="row-fluid"> + <div class="span9 blurb"> + <p>PHP is a popular general-purpose scripting language that is especially suited to web development.</p> + <p>Fast, flexible and pragmatic, PHP powers everything from your blog to the largest social networking site in the world.</p> + </div> + <div class="background span3"></div> + <div class="span3"> + <div class="download-php"> + <h2>Download PHP</h2> + +EOF; +if(!empty($RELEASES[5])) { + $releases = array_chunk($RELEASES[5], 2, $preserve_keys = TRUE); + foreach ($releases as $row) { + $intro .= " + <div class='row-fluid'> +"; + foreach ($row as $version => $release) { + $intro .= " + <div class='span6'> + <p><a class='download-link' href='/downloads.php#v$version'>$version</a></p> + <p class='notes'><a href='/ChangeLog-5.php#$version'>Release Notes</a></p> + </div> +"; + } + $intro .=" + </div> +"; + } } +$intro .= <<<EOF + </div> + </div> + </div> +EOF; + +// Write out common header +site_header("Hypertext Preprocessor", + array( + 'current' => 'home', + 'headtags' => array( + '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', + '<script type="text/javascript">', + "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", + "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", + '</script>' + ), + 'link' => array( + array( + "rel" => "search", + "type" => "application/opensearchdescription+xml", + "href" => $MYSITE . "phpnetimprovedsearch.src", + "title" => "Add PHP.net search" + ), + array( + "rel" => "alternate", + "type" => "application/atom+xml", + "href" => $MYSITE . "releases/feed.php", + "title" => "PHP Release feed" + ), + + ), + 'css' => array('home.css'), + 'intro' => $intro + ) +); + +// Print body of home page. +echo $content; + +$SIDEBAR = <<< SIDEBAR_DATA + +$announcements + <p class='panel'><a href='/tips.php'>Tips and Tricks</a></p> + <p class='panel'><a href='/conferences/'>Conferences</a></p> + <p class='panel'><a href='/cal.php'>User Group Events</a></p> + <p class='panel'><a href='/thanks.php'>Special Thanks</a></p> + +SIDEBAR_DATA; + +// Print the common footer. +site_footer( + array( + "atom" => "/feed.atom", // Add a link to the feed at the bottom + 'elephpants' => true, + 'sidebar' => $SIDEBAR + ) +); +
diff --git a/index-beta.php b/index-beta.php deleted file mode 100644 index 612e869..0000000 --- a/index-beta.php +++ /dev/null @@ -1,191 +0,0 @@ -<?php // vim: et -/* - If you're reading this, it isn't because you've found a security hole. - this is an open source website. read and learn! -*/ - -/* ------------------------------------------------------------------------- */ - -// Get the modification date of this PHP file -$timestamps = array(@getlastmod()); - -/* - The date of prepend.inc represents the age of ALL - included files. Please touch it if you modify any - other include file (and the modification affects - the display of the index page). The cost of stat'ing - them all is prohibitive. Also note the file path, - we aren't using the include path here. -*/ -$timestamps[] = @filemtime("include/prepend.inc"); - -// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page -$timestamps[] = @filemtime("include/pregen-events.inc"); -$timestamps[] = @filemtime("include/pregen-confs.inc"); -$timestamps[] = @filemtime("include/pregen-news.inc"); -$timestamps[] = @filemtime("include/version.inc"); - -// The latest of these modification dates is our real Last-Modified date -$timestamp = max($timestamps); - -// Note that this is not a RFC 822 date (the tz is always GMT) -$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; - -// Check if the client has the same page cached -if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && - ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { - header("HTTP/1.1 304 Not Modified"); - exit(); -} -// Inform the user agent what is our last modification date -else { - header("Last-Modified: " . $tsstring); -} - -$_SERVER['BASE_PAGE'] = 'index.php'; -include_once 'include/prepend.inc'; -include_once 'include/pregen-events.inc'; -include_once 'include/pregen-confs.inc'; -include_once 'include/pregen-news.inc'; -include_once 'include/version.inc'; - -// Prepare announcements. -if (is_array($CONF_TEASER) && $CONF_TEASER) { - $teaser_categories = array( - 'conference' => 'Upcoming conferences', - 'cfp' => 'Calling for papers', - ); - - $announcements = '<ul class="announcements">'; - - foreach ($CONF_TEASER as $category => $events) { - if (is_array($events) && $events) { - $announcements .= '<li><span class="category">'.$teaser_categories[$category].':</span><ul>'; - $links = array(); - foreach (array_slice($events, 0, 4) as $url => $title) { - $title = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $title); - $announcements .= "<li><a href='$url'>$title</a></li>"; - } - $announcements .= '</ul>'; - } - } - - $announcements .= '</ul>'; -} else { - $announcements = ''; -} - - -require_once './Gateway/NewsFileSystemGateway.php'; - -$NewsGateway = new NewsFileSystemGateway(); -$RecentNews = $NewsGateway->getArticlesForCategories(array( - "frontpage" -), 4); - -ob_start(); - -require_once './View/HomepageNewsView.php'; -$RecentNewsView = new HomepageNewsView($RecentNews); - -echo $RecentNewsView->render(); - -$news = ob_get_clean(); - -// Wrap announcements and features in a content element -$content = " -<div class='home-content'> - $news -</div> -"; - -$intro = <<<EOF - <div class="row-fluid"> - <div class="span9 blurb"> - <p>PHP is a popular general-purpose scripting language that is especially suited to web development.</p> - <p>Fast, flexible and pragmatic, PHP powers everything from your blog to the largest social networking site in the world.</p> - </div> - <div class="background span3"></div> - <div class="span3"> - <div class="download-php"> - <h2>Download PHP</h2> - -EOF; -if(!empty($RELEASES[5])) { - $releases = array_chunk($RELEASES[5], 2, $preserve_keys = TRUE); - foreach ($releases as $row) { - $intro .= " - <div class='row-fluid'> -"; - foreach ($row as $version => $release) { - $intro .= " - <div class='span6'> - <p><a class='download-link' href='/downloads.php#v$version'>$version</a></p> - <p class='notes'><a href='/ChangeLog-5.php#$version'>Release Notes</a></p> - </div> -"; - } - $intro .=" - </div> -"; - } -} -$intro .= <<<EOF - </div> - </div> - </div> -EOF; - -// Write out common header -site_header("Hypertext Preprocessor", - array( - 'current' => 'home', - 'headtags' => array( - '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', - '<script type="text/javascript">', - "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", - "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", - '</script>' - ), - 'link' => array( - array( - "rel" => "search", - "type" => "application/opensearchdescription+xml", - "href" => $MYSITE . "phpnetimprovedsearch.src", - "title" => "Add PHP.net search" - ), - array( - "rel" => "alternate", - "type" => "application/atom+xml", - "href" => $MYSITE . "releases/feed.php", - "title" => "PHP Release feed" - ), - - ), - 'css' => array('home.css'), - 'intro' => $intro - ) -); - -// Print body of home page. -echo $content; - -$SIDEBAR = <<< SIDEBAR_DATA - -$announcements - <p class='panel'><a href='/tips.php'>Tips and Tricks</a></p> - <p class='panel'><a href='/conferences/'>Conferences</a></p> - <p class='panel'><a href='/cal.php'>User Group Events</a></p> - <p class='panel'><a href='/thanks.php'>Special Thanks</a></p> - -SIDEBAR_DATA; - -// Print the common footer. -site_footer( - array( - "atom" => "/feed.atom", // Add a link to the feed at the bottom - 'elephpants' => true, - 'sidebar' => $SIDEBAR - ) -); - diff --git a/index-stable.php b/index-stable.php deleted file mode 100644 index 37924ee..0000000 --- a/index-stable.php +++ /dev/null @@ -1,271 +0,0 @@ -<?php // vim: et -/* - If you're reading this, it isn't because you've found a security hole. - this is an open source website. read and learn! -*/ - -/* ------------------------------------------------------------------------- */ - -// Get the modification date of this PHP file -$timestamps = array(@getlastmod()); - -/* - The date of prepend.inc represents the age of ALL - included files. Please touch it if you modify any - other include file (and the modification affects - the display of the index page). The cost of stat'ing - them all is prohibitive. Also note the file path, - we aren't using the include path here. -*/ -$timestamps[] = @filemtime("include/prepend.inc"); - -// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page -$timestamps[] = @filemtime("include/pregen-events.inc"); -$timestamps[] = @filemtime("include/pregen-confs.inc"); -$timestamps[] = @filemtime("include/pregen-news.inc"); -$timestamps[] = @filemtime("include/version.inc"); - -// The latest of these modification dates is our real Last-Modified date -$timestamp = max($timestamps); - -// Note that this is not a RFC 822 date (the tz is always GMT) -$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; - -// Check if the client has the same page cached -if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && - ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { - header("HTTP/1.1 304 Not Modified"); - exit(); -} -// Inform the user agent what is our last modification date -else { - header("Last-Modified: " . $tsstring); -} - -$_SERVER['BASE_PAGE'] = 'index.php'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-events.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-confs.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/pregen-news.inc'; -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/version.inc'; - -// This goes to the left sidebar of the front page -$SIDEBAR_DATA = ' -<h3>What is PHP?</h3> -<p> - <acronym title="recursive acronym for PHP: Hypertext Preprocessor">PHP</acronym> - is a widely-used general-purpose scripting language that is - especially suited for Web development and can be embedded into HTML. - If you are new to PHP and want to get some idea - of how it works, try the <a href="/tut.php">introductory tutorial</a>. - After that, check out the online <a href="/docs.php">manual</a>. -</p> -<p> - Ever wondered how popular PHP is? See the - <a href="/usage.php">Netcraft Survey</a>. -</p> - -<h3><a href="/thanks.php">Thanks To</a></h3> -<ul class="simple"> - <li><a href="http://www.easydns.com/?V=698570efeb62a6e2" title="DNS Hosting provided by easyDNS">easyDNS</a></li> - <li><a href="http://www.directi.com/">Directi</a></li> - <li><a href="http://promote.pair.com/direct.pl?php.net">pair Networks</a></li> - <li><a href="http://www.servercentral.net/">Server Central</a></li> - <li><a href="http://www.hostedsolutions.com/">Hosted Solutions</a></li> - <li><a href="http://www.spry.com/">Spry VPS Hosting</a></li> - <li><a href="http://www.osuosl.org">OSU Open Source Lab</a></li> - <li><a href="http://www.yahoo.com/">Yahoo! Inc.</a></li> - <li><a href="http://www.nexcess.net/">NEXCESS.NET</a></li> - <li><a href="http://www.rackspace.com/">Rackspace</a></li> - <li><a href="http://www.eukhost.com/">EUKhost</a></li> - <li><a href="http://www.sohosted.nl/webhosting/">SoHosted Webhosting</a></li> - <li><a href="http://www.redpill-linpro.com">Redpill Linpro</a></li> - <li><a href="http://www.facebook.com">Facebook</a></li> - <li><a href="http://krystal.co.uk">Krystal.co.uk</a></li> - <li><a href="http://servergrove.com/">ServerGrove</a></li> - <li><a href="http://www.bauer-kirch.de/">Bauer + Kirch GmbH</a></li> -</ul> -<h3>Related sites</h3> -<ul class="simple"> - <li><a href="http://www.apache.org/">Apache</a></li> - <li><a href="http://www.mysql.com/">MySQL</a></li> - <li><a href="http://www.postgresql.org/">PostgreSQL</a></li> - <li><a href="http://www.zend.com/">Zend Technologies</a></li> -</ul> -<h3>Community</h3> -<ul class="simple"> - <li><a href="http://www.linuxfund.org/">LinuxFund.org</a></li> - <li><a href="http://ostg.com/">OSTG</a></li> -</ul> - -<h3>Syndication</h3> -<p> - You can grab our news as an <a href="/feed.atom">Atom feed</a>. -</p>'; - -$MIRROR_IMAGE = ''; - -// Try to find a sponsor image in case this is an official mirror -if (is_official_mirror()) { - - // Iterate through possible mirror provider logo types in priority order - $types = array("gif", "jpg", "png"); - while (list(,$ext) = each($types)) { - - // Check if file exists for this type - if (file_exists("backend/mirror." . $ext)) { - - // Add text to rigth sidebar - $MIRROR_IMAGE = "<div align=\"center\"><h3>This mirror sponsored by:</h3>\n"; - - // Create image HTML code - $img = make_image( - 'mirror.' . $ext, - htmlspecialchars(mirror_provider()), - FALSE, - FALSE, - 'backend', - 0 - ); - - // Add size information depending on mirror type - if (is_primary_site() || is_backup_primary()) { - $img = resize_image($img, 125, 125); - } else { - $img = resize_image($img, 120, 60); - } - - // End mirror specific part - $MIRROR_IMAGE .= '<a href="' . mirror_provider_url() . '">' . - $img . "</a></div><br /><hr />\n"; - - // We have found an image - break; - } - } -} - -/* {{{ Generate latest release info */ -/* NOTE: You are editing the wrong file, you should be in include/version.inc - * For RC: See the $PHP_x_RC variable - * For STABLE: See the $PHP_x_VERSION/_DATE/_MD5 variables - */ -$PHP_5_STABLE = array(); -$PHP_5_RC = array(); -$rel = $rc = ""; - -$SHOW_COUNT = 3; -for ($i=1; $i<=$SHOW_COUNT; ++$i) { -list($PHP_5_STABLE, ) = each($RELEASES[5]); - -$minor = round($PHP_5_STABLE, 1); -$rel .= <<< EOT - <li class="php5"><a href="/downloads.php#v5">Current PHP $minor Stable: <span class="release">$PHP_5_STABLE</span></a></li> -EOT; -} - -/* Do we have any release candidates to brag about? */ -$RCS = array( - $PHP_5_5_RC => $PHP_5_5_RC_DATE, - $PHP_5_4_RC => $PHP_5_4_RC_DATE, - $PHP_5_3_RC => $PHP_5_3_RC_DATE, -); -if (isset($RCS)) { - foreach ((array)$RCS as $r => $d) { - if ($r) { - $rc .= ' <li class="php5"><a href="http://qa.php.net/"><span class="release">' . "$r ($d)</span></a></li>\n"; - } - } -} - -$rel = <<< EOT - <div id="releaseBox"> - <h4>Stable Releases</h4> - <ol id="releases"> - $rel - </ol> - </div>\n -EOT; - -if (!empty($rc)) { - $rel .= <<< EOT - <div id="candidateBox"> - <h4><a href="http://qa.php.net/rc.php">Release Candidates</a></h4> - <ol id="candidates"> -$rc - </ol> - </div>\n -EOT; -} -/* }}} */ - -// Prepend mirror image & latest releases to sidebar text -$RSIDEBAR_DATA = $MIRROR_IMAGE . $rel . $RSIDEBAR_DATA; - -// Write out common header -site_header("Hypertext Preprocessor", - array( - 'current' => 'home', - 'onload' => 'boldEvents();', - 'headtags' => array( - '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', - '<script type="text/javascript">', - "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", - "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", - '</script>' - ), - 'link' => array( - array( - "rel" => "search", - "type" => "application/opensearchdescription+xml", - "href" => $MYSITE . "phpnetimprovedsearch.src", - "title" => "Add PHP.net search" - ), - array( - "rel" => "alternate", - "type" => "application/atom+xml", - "href" => $MYSITE . "releases/feed.php", - "title" => "PHP Release feed" - ), - - ), - ) -); - -if (is_array($CONF_TEASER) && count($CONF_TEASER)) { - $categories = array("conference" => "Upcoming conferences", "cfp" => "Calling for papers"); - echo ' <div id="confTeaser">' . "\n"; - echo " <table>\n"; - foreach($CONF_TEASER as $k => $a) { - if (is_array($a) && count($a)) { - echo " <tr>\n <td valign='top' style='white-space: nowrap'>".$categories[$k].":</td>\n"; - echo " <td valign='top'>\n"; - echo ' <ul class="' .$k. '">' . "\n"; - $count = 0; - $a = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $a); - foreach($a as $url => $title) { - if ($count++ >= 4) { - break; - } - echo ' <li><a href="' . $url. '">' . $title. '</a></li>' . "\n"; - } - echo " </ul>\n </td>\n </tr>\n"; - } // if set - } - echo " </table>\n </div>\n\n<br />\n"; -} - - -/* Where the h*ll did all the news go? - * See archives/2007.xml - */ -print_news($NEWS_ENTRIES, "frontpage"); -?> - -<p class="center"><a href="/archive/index.php">News Archive</a></p> - -<?php -site_footer( - array("atom" => "/feed.atom") // Add a link to the feed at the bottom -); - diff --git a/index.php b/index.php index fc4c55a..612e869 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,191 @@ <?php // vim: et +/* + If you're reading this, it isn't because you've found a security hole. + this is an open source website. read and learn! +*/ -// show beta home page if user has requested the beta site. -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; -if (myphpnet_beta()) { - include $_SERVER['DOCUMENT_ROOT'] . '/index-beta.php'; +/* ------------------------------------------------------------------------- */ + +// Get the modification date of this PHP file +$timestamps = array(@getlastmod()); + +/* + The date of prepend.inc represents the age of ALL + included files. Please touch it if you modify any + other include file (and the modification affects + the display of the index page). The cost of stat'ing + them all is prohibitive. Also note the file path, + we aren't using the include path here. +*/ +$timestamps[] = @filemtime("include/prepend.inc"); + +// Calendar, conference teasers & latest releaes box are the only "dynamic" features on this page +$timestamps[] = @filemtime("include/pregen-events.inc"); +$timestamps[] = @filemtime("include/pregen-confs.inc"); +$timestamps[] = @filemtime("include/pregen-news.inc"); +$timestamps[] = @filemtime("include/version.inc"); + +// The latest of these modification dates is our real Last-Modified date +$timestamp = max($timestamps); + +// Note that this is not a RFC 822 date (the tz is always GMT) +$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; + +// Check if the client has the same page cached +if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && + ($_SERVER["HTTP_IF_MODIFIED_SINCE"] == $tsstring)) { + header("HTTP/1.1 304 Not Modified"); + exit(); +} +// Inform the user agent what is our last modification date +else { + header("Last-Modified: " . $tsstring); +} + +$_SERVER['BASE_PAGE'] = 'index.php'; +include_once 'include/prepend.inc'; +include_once 'include/pregen-events.inc'; +include_once 'include/pregen-confs.inc'; +include_once 'include/pregen-news.inc'; +include_once 'include/version.inc'; + +// Prepare announcements. +if (is_array($CONF_TEASER) && $CONF_TEASER) { + $teaser_categories = array( + 'conference' => 'Upcoming conferences', + 'cfp' => 'Calling for papers', + ); + + $announcements = '<ul class="announcements">'; + + foreach ($CONF_TEASER as $category => $events) { + if (is_array($events) && $events) { + $announcements .= '<li><span class="category">'.$teaser_categories[$category].':</span><ul>'; + $links = array(); + foreach (array_slice($events, 0, 4) as $url => $title) { + $title = preg_replace("'([A-Za-z0-9])([\s\:\-\,]*?)call for(.*?)$'i", "$1", $title); + $announcements .= "<li><a href='$url'>$title</a></li>"; + } + $announcements .= '</ul>'; + } + } + + $announcements .= '</ul>'; } else { - include $_SERVER['DOCUMENT_ROOT'] . '/index-stable.php'; + $announcements = ''; +} + + +require_once './Gateway/NewsFileSystemGateway.php'; + +$NewsGateway = new NewsFileSystemGateway(); +$RecentNews = $NewsGateway->getArticlesForCategories(array( + "frontpage" +), 4); + +ob_start(); + +require_once './View/HomepageNewsView.php'; +$RecentNewsView = new HomepageNewsView($RecentNews); + +echo $RecentNewsView->render(); + +$news = ob_get_clean(); + +// Wrap announcements and features in a content element +$content = " +<div class='home-content'> + $news +</div> +"; + +$intro = <<<EOF + <div class="row-fluid"> + <div class="span9 blurb"> + <p>PHP is a popular general-purpose scripting language that is especially suited to web development.</p> + <p>Fast, flexible and pragmatic, PHP powers everything from your blog to the largest social networking site in the world.</p> + </div> + <div class="background span3"></div> + <div class="span3"> + <div class="download-php"> + <h2>Download PHP</h2> + +EOF; +if(!empty($RELEASES[5])) { + $releases = array_chunk($RELEASES[5], 2, $preserve_keys = TRUE); + foreach ($releases as $row) { + $intro .= " + <div class='row-fluid'> +"; + foreach ($row as $version => $release) { + $intro .= " + <div class='span6'> + <p><a class='download-link' href='/downloads.php#v$version'>$version</a></p> + <p class='notes'><a href='/ChangeLog-5.php#$version'>Release Notes</a></p> + </div> +"; + } + $intro .=" + </div> +"; + } } +$intro .= <<<EOF + </div> + </div> + </div> +EOF; + +// Write out common header +site_header("Hypertext Preprocessor", + array( + 'current' => 'home', + 'headtags' => array( + '<link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="' . $MYSITE . 'feed.atom" />', + '<script type="text/javascript">', + "function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}", + "okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='".$_SERVER['STATIC_ROOT']."/images/php_konami.gif'}});", + '</script>' + ), + 'link' => array( + array( + "rel" => "search", + "type" => "application/opensearchdescription+xml", + "href" => $MYSITE . "phpnetimprovedsearch.src", + "title" => "Add PHP.net search" + ), + array( + "rel" => "alternate", + "type" => "application/atom+xml", + "href" => $MYSITE . "releases/feed.php", + "title" => "PHP Release feed" + ), + + ), + 'css' => array('home.css'), + 'intro' => $intro + ) +); + +// Print body of home page. +echo $content; + +$SIDEBAR = <<< SIDEBAR_DATA + +$announcements + <p class='panel'><a href='/tips.php'>Tips and Tricks</a></p> + <p class='panel'><a href='/conferences/'>Conferences</a></p> + <p class='panel'><a href='/cal.php'>User Group Events</a></p> + <p class='panel'><a href='/thanks.php'>Special Thanks</a></p> + +SIDEBAR_DATA; + +// Print the common footer. +site_footer( + array( + "atom" => "/feed.atom", // Add a link to the feed at the bottom + 'elephpants' => true, + 'sidebar' => $SIDEBAR + ) +); +