' . str_replace(
array(
' ',
'\n",
'';
if ($return) { return $highlighted; }
else { echo $highlighted; }
}
/* These functions are only used on the new XHTML 1.0 Strict compatible
pages, and are used as an experiment, but are going to replace the
commonHeader and commonFooter functions in the future altogether */
function site_header($title = '', $config = array())
{
global $EXPL_LANG;
// Default to empty array if improper parameter passed
if (!is_array($config)) { $config = array(); }
// String defaults
$lang_input = $base = $meta = '';
// Print out lang and charset headers
if (!isset($config["lang"])) { $config["lang"] = "en"; }
if (!isset($config["charset"])) { $config["charset"] = "ISO-8859-1"; }
header("Content-type: text/html;charset={$config['charset']}");
header("Content-language: {$config['lang']}");
if (!empty($title)) { $title = ": $title"; }
// This page should not be indexed by robots
if (in_array("noindex", $config)) {
$meta .= "\n ";
}
// Decide on onload event handler
if (!isset($config['onload'])) {
$config['onload'] = "searchHistory(); tocImages();";
}
// Explicit language setting means that we should put that into the form
if (isset($EXPL_LANG)) {
$lang_input = "\n ";
}
// Base href setting for URL shortcuts to work
if (!empty($_SERVER['BASE_HREF'])) {
$base = "\n ";
}
print <<PHP{$title}
$base$meta
END_FOOTER;
}
// Print an image for a sized spacer
function spacer($width = 1, $height = 1, $return = FALSE, $align = FALSE, $extras = FALSE)
{
$function = ($return ? "sprintf" : "printf");
return $function('',
$_SERVER['STATIC_ROOT'],
$width,
$height,
($align ? " align=\"$align\" " : ""),
($extras ? " $extras" : "")
);
}
// 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('',
$webdir,
$file,
($alt ? $alt : ''),
$sizeparams,
$align,
($extras ? ' ' . $extras : '')
);
return $image;
}
// 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)
{
echo "" . make_image("news/$image", $alt, "right") . "";
}
// 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),
($target ? $target : "_new"),
htmlspecialchars($url),
($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 ']';
}
}
}
$enclosed = 0;
# commonheader()
#
#
function commonHeader($title="",$dont_enclose=0,$headers_gone=0) {
global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA,
$SEARCH_BASE, $ONLOAD;
// If no onload event is specified, restore the last search
if (empty($ONLOAD)) { $ONLOAD = "searchHistory(); tocImages();"; }
// Guess what base to use for this page (the first two are just
// for BC reasons, until we migrate all the code to use the last one)
unset($PBASE);
if (!empty($SEARCH_BASE)) { $PBASE = $SEARCH_BASE; }
if (!empty($_SERVER['BASE_HREF'])) { $PBASE = $_SERVER['BASE_HREF']; }
?>
PHP
' : ''); ?>
tags make things look awfully weird (breaks things out of the
tag). Just convert them to 's
*/
$text = str_replace (array ('
', '
'), ' ', $text);
/* Remove
tags to prevent it from showing up in the note */
$text = str_replace (array ('
', ''), '', $text);
/* preserve linebreaks */
$text = str_replace("\n", " ", $text);
/* this will only break long lines */
if (function_exists("wordwrap")) {
$text = wordwrap($text);
}
// Preserve spacing of user notes
$text = str_replace(" ", " ", $text);
$text = "".$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;
// 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'
);
if (!isset($event['start'])) { $event['start'] = ""; }
if (!isset($event['end'])) { $event['end'] = ""; }
if (!isset($event['sday'])) { $event['sday'] = ""; }
if (!isset($event['smonth'])) { $event['smonth'] = ""; }
if (!isset($event['syear'])) { $event['syear'] = ""; }
if (!isset($event['eday'])) { $event['eday'] = ""; }
if (!isset($event['emonth'])) { $event['emonth'] = ""; }
if (!isset($event['eyear'])) { $event['eyear'] = ""; }
// Start and end day of this event
$sday = $event['start'] ? strtotime($event['start'])
: mktime(0, 0, 1, $event['smonth'], $event['sday'], $event['syear']);
$eday = $event['end'] ? strtotime($event['end'])
: mktime(0, 0, 1, $event['emonth'], $event['eday'], $event['eyear']);
?>
", 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'])), "";
// End link
if ($event['url']) { echo ""; }
// Print extra date info for recurring and multiday events
switch ($event['type']) {
case 2:
case 'multi':
echo " (", date("Y-m-d",$sday), " to ", date("Y-m-d",$eday), ")";
break;
case 3:
case 'recur':
echo " (Every ", $re[$event['recur']], " ",
$days[$event['recur_day']], " 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($event['ldesc']));
// If we have an URL, print it out
if ($event['url']) {
echo '