")) $highlighted = ''.nl2br(htmlentities($code)).""; // Fix output to use CSS classes and wrap well $highlighted = '
' . str_replace( array( ' ', '
', '', "\n ", ' ', ' ' ), array( ' ', "
\n", '', "\n ", '  ', '  ' ), $highlighted ) . '
'; if ($return) { return $highlighted; } else { echo $highlighted; } } // Stats pages still need this function commonHeader($title) { site_header($title); } function site_header($title = '', $config = array()) { if (myphpnet_beta()) { return site_header_beta($title, $config); } global $EXPL_LANG, $SIDEBAR_DATA, $RSIDEBAR_DATA, $PAGE_COLUMNS, $PGI; // Default to empty array if improper parameter passed if (!is_array($config)) { $config = array(); } // String defaults $lang_input = $canonical = $base = $meta = $layout_helper = ''; // Count number of columns for layout. The number identifies // the layout precisely, as we have no page having a right // sidebar and no left sidebar $PAGE_COLUMNS = 1; if (!empty($SIDEBAR_DATA)) { $PAGE_COLUMNS++; } if (!empty($RSIDEBAR_DATA)) { $PAGE_COLUMNS++; } // Check which language we are presenting, default to english $lang = "en"; if (isset($config["lang"])) { $lang = language_convert($config["lang"]); } elseif (isset($PGI, $PGI['head'], $PGI['head'][1])) { $lang = language_convert($PGI['head'][1]); } // Print out lang and charset headers if (!isset($config["charset"])) { $config["charset"] = "utf-8"; } header("Content-type: text/html;charset={$config['charset']}"); header("Content-language: {$lang}"); if (isset($config["generate_modified"]) && $config["generate_modified"]) { $timestamp = @filemtime($_SERVER["DOCUMENT_ROOT"] . "/" .$_SERVER["BASE_PAGE"]); if ($timestamp) { $tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; header("Last-Modified: " . $tsstring); } } if (isset($config["extra_headers"]) && is_array($config["extra_headers"])) { foreach($config["extra_headers"] as $key => $value) { header(sprintf("%s: %s", $key, $value)); } } if (!empty($title)) { $title = ": $title"; } // This page should not be indexed by robots if (in_array("noindex", $config)) { $meta .= "\n "; } // Set onload handler if required $onload = (isset($config['onload']) ? ' onload="' . $config['onload'] . '"' : ''); // Explicit language setting means that we should put that into the form if (isset($EXPL_LANG)) { $lang_input = "\n "; } // Link tags $link = ""; if (isset($config['link']) && is_array($config['link'])) { foreach($config['link'] as $rel => $url) { if (!is_array($url)) { $link .= "\n "; } else { $link .= "\n $val) { $link .= "$attr=\"$val\" "; } $link .= "/>"; } } } // Base href setting for URL shortcuts to work if (!empty($_SERVER['BASE_HREF'])) { $base = "\n "; $canonical = ''; } // Define layout helper in case we need it if ($PAGE_COLUMNS > 2) { $layout_helper = "
"; } // Choose name of mirror site specific CSS file $mirror_specific_style = ($_SERVER['STATIC_ROOT'] ? 'phpnet' : 'mirror'); // Support for more header tags $moreheadtags = ''; if (isset($config['headtags'])) { if (is_array($config['headtags'])) { $moreheadtags = "\n " . join("\n ", $config['headtags']); } else { $moreheadtags = "\n " . ((string)$config['headtags']); } } $classname = "default"; if(isset($_SERVER['BASE_PAGE'])) { $classname = dirname($_SERVER['BASE_PAGE']); if(empty($classname)) { $classname = "default"; } } // Right-to-left support $rtl = ""; /* Does not appear to work... commenting out. switch ($lang) { case "he": case "ar": $rtl = ' style="direction: rtl"'; break; } */ // RTL Hack. Edit styles/rtl.css for rtl specific CSS. $import_rtl = ''; if (in_array($lang, array('ar', 'fa', 'he'))) { $import_rtl = '@import url("' . $_SERVER['STATIC_ROOT'] . '/styles/rtl.css");'; } $profile = ""; if (isset($config['profile']) && !empty($config['profile'])) { $profile = ' profile="'; if (is_array($config['profile'])) { $profile .= implode(" ", $config['profile']); } else { $profile .= $config['profile']; } $profile .= '"'; } print << PHP{$title} {$link} $canonical {$base}{$meta}{$moreheadtags}

search for in the {$lang_input}

{$layout_helper} END_HEADER; // Print out left column if ($PAGE_COLUMNS > 1) { echo "\n
\n$SIDEBAR_DATA\n
"; } // Print out right column if ($PAGE_COLUMNS > 2) { echo "\n
\n$RSIDEBAR_DATA\n
"; } // Any layout workarounds? if (!empty($config["layout_workaround"])) { echo $config["layout_workaround"]; } // Start main page content echo "\n
\n"; } // Stats pages still need this function commonFooter() { site_footer(); } function site_footer($config = array()) { if (myphpnet_beta()) { return site_footer_beta($config); } global $LAST_UPDATED, $PAGE_COLUMNS; $stats = (have_stats() ? "\n stats |" : ""); $rsslink = (isset($config["rss"]) ? "RSS |" : ""); $atomlink = (isset($config["atom"]) ? "Atom |" : ""); $viewsource = (isset($_SERVER['BASE_PAGE']) ? "show source |" : ""); $provider_url = mirror_provider_url(); $provider_name = mirror_provider(); $mirror_text = (is_official_mirror() ? "This mirror generously provided by:" : "This unofficial mirror is operated at:"); $last_updated = strftime("%c %Z", $LAST_UPDATED); $layout_helper = ($PAGE_COLUMNS > 2 ? "
" : ""); //$functionsjs = (in_array("functionsjs", $config) ? "\n' : ''); // Automate the Copyright year $current_year = date('Y'); print <<
 
{$layout_helper}
$rsslink $atomlink $viewsource credits |$stats sitemap | contact | advertising | mirror sites
END_FOOTER; } // Resize the image using the output of make_image() // (considering possible HTML/XHTML image tag endings) function resize_image($img, $width = 1, $height = 1) { // Drop width and height values from image if available $str = preg_replace('!width=\"([0-9]+?)\"!i', '', $img); $str = preg_replace('!height=\"([0-9]+?)\"!i', '', $str); // Return image with new width and height added return preg_replace( '!/?>$!', sprintf(' height="%s" width="%s" />', $height, $width), $str ); } // Return an tag for a given image file available on the server function make_image($file, $alt = FALSE, $align = FALSE, $extras = FALSE, $dir = '/images', $border = 0, $addsize = TRUE) { // If no / was provided at the start of $dir, add it $webdir = $_SERVER['STATIC_ROOT'] . ($dir{0} == '/' ? '' : '/') . $dir; // Get width and height values if possible if ($addsize && ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'] . "$dir/$file"))) { $sizeparams = ' ' . trim($size[3]); } else { $sizeparams = ''; } // Convert right or left alignment to CSS float, // but leave other alignments intact (for now) if (in_array($align, array("right", "left"))) { $align = ' style="float: ' . $align . ';"'; } elseif ($align) { $align = ' align="' . $align . '"'; } else { $align = ''; } // Return with image built up return sprintf('%s', $webdir, $file, ($alt ? $alt : ''), $sizeparams, $align, ($extras ? ' ' . $extras : '') ); } // Print an tag out for a given file function print_image($file, $alt = FALSE, $align = FALSE, $extras = FALSE, $dir = '/images', $border = 0) { echo make_image($file, $alt, $align, $extras, $dir, $border); } // Shortcut to usual news image printing (right floating // image from the news dir with an alt and an URL) function news_image($URL, $image, $alt, $print = true) { $str = "" . make_image("news/$image", $alt, "right") . ""; if ($print) { echo $str; } return $str; } // Return HTML code for a submit button image function make_submit($file, $alt = FALSE, $align = FALSE, $extras = FALSE, $dir = '/images', $border = 0) { // Get an image without size info and convert the // border attribute to use CSS, as border="" is not // supported on elements in [X]HTML $img = make_image($file, $alt, $align, $extras, $dir, 0, FALSE); $img = str_replace( "border=\"$border\"", "style=\"border: {$border}px;\"", $img ); // Return with ready input image return '%s", $url, ($target ? ' target="' . $target . '"' : ''), ($extras ? ' ' . $extras : ''), ($linktext ? $linktext : $url) ); } // Print a hyperlink to something, within the site function print_link($url, $linktext = FALSE, $target = FALSE, $extras = FALSE) { echo make_link($url, $linktext, $target, $extras); } // make_popup_link() // return a hyperlink to something, within the site, that pops up a new window // function make_popup_link ($url, $linktext=false, $target=false, $windowprops="", $extras=false) { return sprintf("%s", htmlspecialchars($url, ENT_QUOTES | ENT_IGNORE), ($target ? $target : "_new"), htmlspecialchars($url, ENT_QUOTES | ENT_IGNORE), ($target ? $target : "_new"), $windowprops, ($extras ? ' '.$extras : ''), ($linktext ? $linktext : $url) ); } // print_popup_link() // print a hyperlink to something, within the site, that pops up a new window // function print_popup_link($url, $linktext=false, $windowprops="", $target=false, $extras=false) { echo make_popup_link($url, $linktext, $windowprops, $target, $extras); } // Print a link for a downloadable file (including filesize) function download_link($file, $title, $showsize = TRUE, $mirror = '') { // Construct the download link for this site or a mirror site $download_link = "get/$file/from/a/mirror"; if ($mirror != '') { $download_link = $mirror . $download_link; } else { $download_link = "/" . $download_link; } // Print out the download link print_link($download_link, $title); // Size display is required if ($showsize) { // We have a full path or a relative to the distributions dir if ($tmp = strrchr($file, "/")) { $local_file = substr($tmp, 1, strlen($tmp)); } else { $local_file = "distributions/$file"; } // Try to get the size of the file $size = @filesize($local_file); // Print out size in bytes (if size is // less then 1Kb, or else in Kb) if ($size) { echo ' ['; if ($size < 1024) { echo number_format($size, 0, '.', ',') . 'b'; } else { echo number_format($size/1024, 0, '.', ',') . 'Kb'; } echo ']'; } } } function sect_to_file($string) { $string = strtolower($string); $string = str_replace(' ','-',$string); $string = str_replace('_','-',$string); $func = "function.$string.php"; $chap = "ref.$string.php"; $feat = "features.$string.php"; $struct = "control-structures.$string.php"; if(@is_file($func)) return $func; else if(@is_file($chap)) return $chap; else if(@is_file($feat)) return $feat; else if(@is_file($struct)) return $struct; else return "$string.php"; } function clean($var) { return htmlspecialchars(get_magic_quotes_gpc() ? stripslashes($var) : $var, ENT_QUOTES); } // Clean out the content of one user note for printing to HTML function clean_note($text) { // Highlight PHP source $text = highlight_php(trim($text), TRUE); // Turn urls into links $text = preg_replace( '!((mailto:|(http|ftp|nntp|news):\/\/).*?)(\s|<|\)|"|\\\\|\'|$)!', '\1\4', $text ); return $text; } function display_errors($errors) { echo '
'; if (count($errors) > 1) { echo "You need to do the following before your submission will be accepted:
    "; foreach ($errors as $error) { echo "
  • $error
  • \n"; } echo "
"; } else { echo $errors[0]; } echo '
'; } // Displays an event. Used in event submission // previews and event information displays function display_event($event, $include_date = 1) { global $COUNTRIES; // Current month (int)($_GET['cm'] ?: 0) global $cm; // Current year (int)($_GET['cy'] ?: 0) global $cy; // Weekday names array for ($i = 1; $i <= 7; $i++) { $days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i, 2001)); } // Recurring possibilities $re = array( 1 => 'First', 2 => 'Second', 3 => 'Third', 4 => 'Fourth', -1 => 'Last', -2 => '2nd Last', -3 => '3rd Last' ); $sday = (isset($event['start']) && !empty($event['start'])) ? strtotime($event['start']) : 0; $eday = (isset($event['end']) && !empty($event['end'])) ? strtotime($event['end']) : 0; ?>
", date("F j, Y", $sday), "\n"; } // Print link in case we have one if ($event['url']) { echo ''; } // Print event description echo "", stripslashes(htmlentities($event['sdesc'], ENT_QUOTES | ENT_IGNORE, 'UTF-8')), ""; // End link if ($event['url']) { echo ""; } // Print extra date info for recurring and multiday events switch ($event['type']) { case 2: case 'multi': $dtend = date("Y-m-d", strtotime("+1 day", $eday)); echo " (", date("Y-m-d",$sday), " to ", date("Y-m-d",$eday), ")"; break; case 3: case 'recur': $days = $re[$event['recur']]. " " .$days[$event['recur_day']]; if (!$cm || $cy) { $cm = date("m"); $cy = date("Y"); } $month = date("M", mktime(0, 0, 0, $cm, 1, $cy)); $dtstart = date("Y-m-d", strtotime($days . ' 0st' .$month. ' ' .$cy)); echo ' (Every ', $days, " of the month)"; break; } // Event category if(isset($event['category']) && $event['category']) { $cat = array("unknown", "User Group Event", "Conference", "Training"); echo ' [' . $cat[$event['category']] . '] '; } // Print out country information echo ' (' , $COUNTRIES[$event['country']] , ')'; ?>

", trim(htmlentities($event['ldesc'],ENT_QUOTES | ENT_IGNORE, 'UTF-8'))); // If we have an URL, print it out if ($event['url']) { echo '

URL: ', '', htmlentities($event['url'], ENT_QUOTES | ENT_IGNORE, 'UTF-8'), ''; } ?>
Latest news

For the latest news, check the homepage, or our Atom feed.

Archives by year

    '; for ($i = date("Y"); $i >= 1998; $i--) { $pagename = "archive/$i.php"; $classname = ($pagename == $_SERVER['BASE_PAGE'] ? ' class="active"' : ''); $SIDEBAR_DATA .= "{$i}\n"; } $SIDEBAR_DATA .= '
'; } // Print news function print_news($news, $dog, $max = 5, $onlyyear = null, $return = false) { $retval = array(); $count = 0; $news = $news ? $news : array(); // default to empty array (if no news) foreach($news as $item) { $vevent = ""; $ok = false; // Only print entries in the provided s/dog/cat/ egory // If its a conference, use the hCalendar container foreach($item["category"] as $category) { if (in_array($category["term"], (array)$dog)) { $ok = true; ++$count; } if ($category["term"] === "conferences" || $category["term"] === "cfp") { $vevent = " vevent"; } } if ($count > $max) { break; } if ($ok === false) { continue; } $image = ""; if(isset($item["newsImage"])) { $image = news_image($item["newsImage"]["link"], $item["newsImage"]["content"], $item["newsImage"]["title"], false); } //$id = parse_url($item["id"], PHP_URL_FRAGMENT); 5.1.2 $id = parse_url($item["id"]); $id = $id["fragment"]; // Find the permlink foreach($item["link"] as $link) { if ($link["rel"] === "via") { $permlink = $link["href"]; break; } } if (!isset($permlink)) { $permlink = "#" .$id; } // PHP4 strtotime() doesn't support RFC3339 timestamps $published = substr($item["published"], 0, 10); $nixtimestamp = strtotime($published); $newsdate = date("d-M-Y", $nixtimestamp); if ($onlyyear && date("Y", $nixtimestamp) != $onlyyear) { $count--; continue; } if ($return) { $retval[] = array( "title" => $item["title"], "id" => $id, "permlink" => $permlink, "date" => $newsdate, ); continue; } echo <<< EOT
{$image}

{$item["title"]}

{$newsdate} {$item["content"]}
EOT; } return $retval; } // BETA function site_header_beta($title = '', $config = array()) { global $SIDEBAR_DATA; global $MYSITE; $defaults = array( "lang" => myphpnet_language(), "current" => "", "meta-navigation" => array(), 'classes' => '', 'layout_span' => 9, ); $config = array_merge($defaults, $config); $lang = language_convert($config["lang"]); $curr = $config["current"]; $classes = $config['classes']; if (empty($title)) { $title = "Hypertext Preprocessor"; } // shorturl; http://wiki.snaplog.com/short_url if (isset($_SERVER['BASE_PAGE']) && $shortname = get_shortname($_SERVER["BASE_PAGE"])) { $shorturl = "http://php.net/" . $shortname; } // For static content // FIXME: How does static.php.net work? Will it get the /js/ folders? if (false && ($MYSITE == "http://www.php.net/" || $MYSITE == 'http://php.net/')) { $STATIC_ROOT = "http://static.php.net/www.php.net/"; } elseif (false && !empty($_SERVER["STATIC_ROOT"])) { $STATIC_ROOT = $_SERVER["STATIC_ROOT"]; } else { $STATIC_ROOT = "/"; } require dirname(__FILE__) ."/header.inc"; } function site_footer_beta($config = array()) { require dirname(__FILE__) . "/footer.inc"; } function news_toc($sections = null) { include dirname(__FILE__) . "/pregen-news.inc"; $items = array( "news" => array( "title" => "News", "link" => "/archive/", "children" => print_news($NEWS_ENTRIES, "frontpage", 3, null, true), ), "conferences" => array( "title" => "Conferences", "link" => "/conferences/", "children" => print_news($NEWS_ENTRIES, "conferences", 3, null, true), ), "papers" => array( "title" => "Call for Papers", "link" => "/conferences/", "children" => print_news($NEWS_ENTRIES, "cfp", 3, null, true), ), ); foreach($items as $section => $menu) { // only print requested sections. if (is_array($sections) && !in_array($section, $sections)) { continue; } echo "
{$menu["title"]}
\n"; foreach($menu["children"] as $child) { echo "
{$child["title"]}
\n"; } } } function doc_toc($lang) { $file = dirname(__FILE__) . "/../manual/$lang/toc/index.inc"; if (!file_exists($file)) { $lang = "en"; // Fallback on english if the translation doesn't exist $file = dirname(__FILE__) . "/../manual/en/toc/index.inc"; } require dirname(__FILE__) . "/../manual/$lang/toc/index.inc"; ?>
PHP Manual
{$entry[1]}\n"; } } } function doc_toc_list($lang, $index, $file) { include dirname(__FILE__) . "/../manual/$lang/toc/$file.inc"; doc_toc_title($lang, $index, $file); foreach($TOC as $entry) { echo "\t
{$entry[1]}
\n"; } } function doc_toc_title($lang, $index, $file, $elm = "dt") { foreach($index as $entry) { if ($entry[0] == "$file.php") { $link = $entry[0]; $title = $entry[1]; break; } } echo "<$elm>$title\n"; } /* vim: set et ts=4 sw=4 ft=php: : */