New "special" help file with javascript :-)
[moodle.git] / lib / weblib.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
9fa49e22 3///////////////////////////////////////////////////////////////////////////
4// weblib.php - functions for web output
f9903ed0 5//
9fa49e22 6// Library of all general-purpose Moodle PHP functions and constants
7// that produce HTML output
f9903ed0 8//
9fa49e22 9///////////////////////////////////////////////////////////////////////////
10// //
11// NOTICE OF COPYRIGHT //
12// //
13// Moodle - Modular Object-Oriented Dynamic Learning Environment //
14// http://moodle.com //
15// //
16// Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
17// //
18// This program is free software; you can redistribute it and/or modify //
19// it under the terms of the GNU General Public License as published by //
20// the Free Software Foundation; either version 2 of the License, or //
21// (at your option) any later version. //
22// //
23// This program is distributed in the hope that it will be useful, //
24// but WITHOUT ANY WARRANTY; without even the implied warranty of //
25// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
26// GNU General Public License for more details: //
27// //
28// http://www.gnu.org/copyleft/gpl.html //
29// //
30///////////////////////////////////////////////////////////////////////////
f9903ed0 31
0095d5cd 32/// Constants
33
c1d57101 34/// Define text formatting types ... eventually we can add Wiki, BBcode etc
6901fa79 35define("FORMAT_MOODLE", "0"); // Does all sorts of transformations and filtering
d342c763 36define("FORMAT_HTML", "1"); // Plain HTML (with some tags stripped)
37define("FORMAT_PLAIN", "2"); // Plain text (even tags are printed in full)
38define("FORMAT_WIKI", "3"); // Wiki-formatted text
0095d5cd 39
3fe3851d 40$JAVASCRIPT_TAGS = array("javascript:", "onclick=", "ondblclick=", "onkeydown=", "onkeypress=", "onkeyup=",
41 "onmouseover=", "onmouseout=", "onmousedown=", "onmouseup=",
42 "onblur=", "onfocus=", "onload=", "onselect=");
43
db11e52d 44$ALLOWED_TAGS = "<p><br><b><i><u><font><table><tbody><span><div><tr><td><ol><ul><dl><li><dt><dd><h1><h2><h3><h4><h5><h6><hr><img><a><strong><emphasis><sup><sub><address><cite><blockquote><pre><strike><embed><object><param>";
3fe3851d 45
46
0095d5cd 47/// Functions
48
8553b700 49function s($var) {
c1d57101 50/// returns $var with HTML characters (like "<", ">", etc.) properly quoted,
f9903ed0 51
7d8f674d 52 return htmlSpecialChars(stripslashes_safe($var));
f9903ed0 53}
54
55function p($var) {
c1d57101 56/// prints $var with HTML characters (like "<", ">", etc.) properly quoted,
f9903ed0 57
7d8f674d 58 echo htmlSpecialChars(stripslashes_safe($var));
f9903ed0 59}
60
8553b700 61function nvl(&$var, $default="") {
c1d57101 62/// if $var is undefined, return $default, otherwise return $var
8553b700 63
64 return isset($var) ? $var : $default;
65}
f9903ed0 66
67function strip_querystring($url) {
c1d57101 68/// takes a URL and returns it without the querystring portion
f9903ed0 69
b9b8ab69 70 if ($commapos = strpos($url, '?')) {
71 return substr($url, 0, $commapos);
72 } else {
73 return $url;
74 }
f9903ed0 75}
76
77function get_referer() {
c1d57101 78/// returns the URL of the HTTP_REFERER, less the querystring portion
f9903ed0 79
607809b3 80 return strip_querystring(nvl($_SERVER["HTTP_REFERER"]));
f9903ed0 81}
82
c1d57101 83
f9903ed0 84function me() {
c1d57101 85/// returns the name of the current script, WITH the querystring portion.
eaa50dbc 86/// this function is necessary because PHP_SELF and REQUEST_URI and SCRIPT_NAME
c1d57101 87/// return different things depending on a lot of things like your OS, Web
88/// server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.)
f9903ed0 89
607809b3 90 if (!empty($_SERVER["REQUEST_URI"])) {
91 return $_SERVER["REQUEST_URI"];
c1d57101 92
607809b3 93 } else if (!empty($_SERVER["PHP_SELF"])) {
fced815c 94 if (!empty($_SERVER["QUERY_STRING"])) {
95 return $_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];
96 }
607809b3 97 return $_SERVER["PHP_SELF"];
c1d57101 98
fced815c 99 } else if (!empty($_SERVER["SCRIPT_NAME"])) {
100 if (!empty($_SERVER["QUERY_STRING"])) {
101 return $_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
102 }
103 return $_SERVER["SCRIPT_NAME"];
104
b9b8ab69 105 } else {
fced815c 106 notify("Warning: Could not find any of these web server variables: \$REQUEST_URI, \$PHP_SELF or \$SCRIPT_NAME");
bcdfe14e 107 return false;
7fbd6b1c 108 }
f9903ed0 109}
110
111
f9903ed0 112function qualified_me() {
c1d57101 113/// like me() but returns a full URL
f9903ed0 114
39e018b3 115 if (!empty($_SERVER["HTTP_HOST"])) {
116 $hostname = $_SERVER["HTTP_HOST"];
117 } else if (!empty($_ENV["HTTP_HOST"])) {
118 $hostname = $_ENV["HTTP_HOST"];
119 } else if (!empty($_ENV["SERVER_NAME"])) {
120 $hostname = $_ENV["SERVER_NAME"];
121 } else {
122 notify("Warning: could not find the name of this server!");
bcdfe14e 123 return false;
c1d57101 124 }
f9903ed0 125
607809b3 126 $protocol = (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
39e018b3 127 $url_prefix = $protocol.$hostname;
b9b8ab69 128 return $url_prefix . me();
f9903ed0 129}
130
131
132function match_referer($good_referer = "") {
c1d57101 133/// returns true if the referer is the same as the good_referer. If
87a2fa03 134/// good_referer is not specified, use qualified_me as the good_referer
60f18531 135 global $CFG;
136
ce78926d 137 if (!empty($CFG->buggy_referer)) {
60f18531 138 return true;
139 }
f9903ed0 140
ce78926d 141 if (empty($good_referer)) {
c1d57101 142 $good_referer = qualified_me();
143 }
b9b8ab69 144 return $good_referer == get_referer();
f9903ed0 145}
146
36b4f985 147function data_submitted($url="") {
148/// Used on most forms in Moodle to check for data
149/// Returns the data as an object, if it's found.
607809b3 150/// This object can be used in foreach loops without
151/// casting because it's cast to (array) automatically
36b4f985 152///
153/// Checks that submitted POST data exists, and also
154/// checks the referer against the given url (it uses
155/// the current page if none was specified.
156
37208cd2 157 global $CFG;
158
607809b3 159 if (empty($_POST)) {
36b4f985 160 return false;
607809b3 161
36b4f985 162 } else {
163 if (match_referer($url)) {
607809b3 164 return (object)$_POST;
36b4f985 165 } else {
166 if ($CFG->debug > 10) {
167 notice("The form did not come from this page! (referer = ".get_referer().")");
168 }
169 return false;
170 }
171 }
172}
173
7d8f674d 174function stripslashes_safe($string) {
175/// stripslashes() removes ALL backslashes even from strings
176/// so C:\temp becomes C:temp ... this isn't good.
177/// The following should work as a fairly safe replacement
178/// to be called on quoted AND unquoted strings (to be sure)
179
180 $string = str_replace("\\'", "'", $string);
181 $string = str_replace('\\"', '"', $string);
182 $string = str_replace('\\\\', '\\', $string);
183 return $string;
184}
f9903ed0 185
3fe3851d 186function stri_replace($find, $replace, $string ) {
c1d57101 187/// This does a search and replace, ignoring case
188/// This function is only here because one doesn't exist yet in PHP
189/// Unlike str_replace(), this only works on single values (not arrays)
3fe3851d 190
191 $parts = explode(strtolower($find), strtolower($string));
192
193 $pos = 0;
194
195 foreach ($parts as $key => $part) {
196 $parts[$key] = substr($string, $pos, strlen($part));
197 $pos += strlen($part) + strlen($find);
198 }
199
200 return (join($replace, $parts));
201}
202
f9903ed0 203function read_template($filename, &$var) {
c1d57101 204/// return a (big) string containing the contents of a template file with all
205/// the variables interpolated. all the variables must be in the $var[] array or
206/// object (whatever you decide to use).
207///
208/// WARNING: do not use this on big files!!
f9903ed0 209
b9b8ab69 210 $temp = str_replace("\\", "\\\\", implode(file($filename), ""));
211 $temp = str_replace('"', '\"', $temp);
212 eval("\$template = \"$temp\";");
213 return $template;
f9903ed0 214}
215
216function checked(&$var, $set_value = 1, $unset_value = 0) {
c1d57101 217/// if variable is set, set it to the set_value otherwise set it to the
218/// unset_value. used to handle checkboxes when you are expecting them from
219/// a form
f9903ed0 220
b9b8ab69 221 if (empty($var)) {
222 $var = $unset_value;
223 } else {
224 $var = $set_value;
225 }
f9903ed0 226}
227
228function frmchecked(&$var, $true_value = "checked", $false_value = "") {
c1d57101 229/// prints the word "checked" if a variable is true, otherwise prints nothing,
230/// used for printing the word "checked" in a checkbox form input
f9903ed0 231
b9b8ab69 232 if ($var) {
233 echo $true_value;
234 } else {
235 echo $false_value;
236 }
f9903ed0 237}
238
239
65cf9fc3 240function link_to_popup_window ($url, $name="popup", $linkname="click here", $height=400, $width=500, $title="Popup window") {
c1d57101 241/// This will create a HTML link that will work on both
242/// Javascript and non-javascript browsers.
243/// Relies on the Javascript function openpopup in javascript.php
244/// $url must be relative to home page eg /mod/survey/stuff.php
f9903ed0 245
ff80e012 246 global $CFG;
247
b9b8ab69 248 echo "\n<SCRIPT language=\"Javascript\">";
f9903ed0 249 echo "\n<!--";
ef49e5c3 250 echo "\ndocument.write('<A TITLE=\"$title\" HREF=javascript:openpopup(\"$url\",\"$name\",\"$height\",\"$width\") >".addslashes($linkname)."</A>');";
f9903ed0 251 echo "\n//-->";
b9b8ab69 252 echo "\n</SCRIPT>";
253 echo "\n<NOSCRIPT>\n<A TARGET=\"$name\" TITLE=\"$title\" HREF=\"$CFG->wwwroot/$url\">$linkname</A>\n</NOSCRIPT>\n";
f9903ed0 254
255}
256
257function close_window_button() {
c1d57101 258/// Prints a simple button to close a window
259
f9903ed0 260 echo "<FORM><CENTER>";
e5dfd0f3 261 echo "<INPUT TYPE=button onClick=\"self.close();\" VALUE=\"".get_string("closewindow")."\">";
f9903ed0 262 echo "</CENTER></FORM>";
263}
264
265
08056730 266function choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
c1d57101 267/// Given an array of value, creates a popup menu to be part of a form
268/// $options["value"]["label"]
f9903ed0 269
618b22c5 270 if ($nothing == "choose") {
271 $nothing = get_string("choose")."...";
272 }
273
f9903ed0 274 if ($script) {
275 $javascript = "onChange=\"$script\"";
9c9f7d77 276 } else {
277 $javascript = "";
f9903ed0 278 }
9c9f7d77 279
08056730 280 $output = "<SELECT NAME=$name $javascript>\n";
bda8d43a 281 if ($nothing) {
08056730 282 $output .= " <OPTION VALUE=\"$nothingvalue\"\n";
bda8d43a 283 if ($nothingvalue == $selected) {
08056730 284 $output .= " SELECTED";
bda8d43a 285 }
08056730 286 $output .= ">$nothing</OPTION>\n";
873960de 287 }
607809b3 288 if (!empty($options)) {
289 foreach ($options as $value => $label) {
290 $output .= " <OPTION VALUE=\"$value\"";
291 if ($value == $selected) {
292 $output .= " SELECTED";
293 }
294 if ($label) {
295 $output .= ">$label</OPTION>\n";
296 } else {
297 $output .= ">$value</OPTION>\n";
298 }
f9903ed0 299 }
300 }
08056730 301 $output .= "</SELECT>\n";
302
303 if ($return) {
304 return $output;
305 } else {
306 echo $output;
307 }
f9903ed0 308}
309
d897cae4 310function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false) {
c1d57101 311/// Implements a complete little popup form
312/// $common = the URL up to the point of the variable that changes
313/// $options = A list of value-label pairs for the popup list
314/// $formname = name must be unique on the page
315/// $selected = the option that is already selected
316/// $nothing = The label for the "no choice" option
e5dfd0f3 317/// $help = The name of a help page if help is required
318/// $helptext = The name of the label for the help button
f9903ed0 319
0d0baabf 320 global $CFG;
321
618b22c5 322 if ($nothing == "choose") {
323 $nothing = get_string("choose")."...";
324 }
325
dfec7b01 326 $startoutput = "<form target=\"{$CFG->framename}\" name=$formname>";
2bc269fd 327 $output = "<select name=popup onchange=\"top.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
f9903ed0 328
329 if ($nothing != "") {
dfec7b01 330 $output .= " <option value=\"javascript:void(0)\">$nothing</option>\n";
f9903ed0 331 }
332
333 foreach ($options as $value => $label) {
d897cae4 334 if (substr($label,0,1) == "-") {
dfec7b01 335 $output .= " <option value=\"\"";
d897cae4 336 } else {
dfec7b01 337 $output .= " <option value=\"$common$value\"";
d897cae4 338 if ($value == $selected) {
dfec7b01 339 $output .= " selected";
d897cae4 340 }
f9903ed0 341 }
342 if ($label) {
dfec7b01 343 $output .= ">$label</option>\n";
f9903ed0 344 } else {
dfec7b01 345 $output .= ">$value</option>\n";
f9903ed0 346 }
347 }
dfec7b01 348 $output .= "</select>";
349 $output .= "</form>\n";
d897cae4 350
351 if ($return) {
dfec7b01 352 return $startoutput.$output;
d897cae4 353 } else {
dfec7b01 354 echo $startoutput;
9c9f7d77 355 if ($help) {
356 helpbutton($help, $helptext);
357 }
d897cae4 358 echo $output;
359 }
f9903ed0 360}
361
362
363
364function formerr($error) {
c1d57101 365/// Prints some red text
f9903ed0 366 if (!empty($error)) {
367 echo "<font color=#ff0000>$error</font>";
368 }
369}
370
371
372function validate_email ($address) {
c1d57101 373/// Validates an email to make it makes sense.
f9903ed0 374 return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
375 '@'.
376 '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
377 '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
378 $address));
379}
380
6ed3da1d 381function get_slash_arguments($file="file.php") {
382/// Searches the current environment variables for some slash arguments
f9903ed0 383
eaa50dbc 384 if (!$string = me()) {
f9903ed0 385 return false;
386 }
eaa50dbc 387
6ed3da1d 388 $pathinfo = explode($file, $string);
389
bcdfe14e 390 if (!empty($pathinfo[1])) {
391 return $pathinfo[1];
6ed3da1d 392 } else {
393 return false;
394 }
395}
396
397function parse_slash_arguments($string, $i=0) {
398/// Extracts arguments from "/foo/bar/something"
399/// eg http://mysite.com/script.php/foo/bar/something
f9903ed0 400
6ed3da1d 401 if (strpos($string, "..")) { // check for parent URLs
780db230 402 return false;
403 }
6ed3da1d 404 if (strpos($string, "|")) { // check for pipes
780db230 405 return false;
406 }
6ed3da1d 407 if (strpos($string, "`")) { // check for backquotes
e2d89725 408 return false;
409 }
410
6ed3da1d 411 $args = explode("/", $string);
f9903ed0 412
413 if ($i) { // return just the required argument
414 return $args[$i];
415
416 } else { // return the whole array
417 array_shift($args); // get rid of the empty first one
418 return $args;
419 }
420}
421
0095d5cd 422function format_text_menu() {
c1d57101 423/// Just returns an array of formats suitable for a popup menu
0095d5cd 424 return array (FORMAT_MOODLE => get_string("formattext"),
6901fa79 425 FORMAT_HTML => get_string("formathtml"),
d342c763 426 FORMAT_PLAIN => get_string("formatplain"),
427 FORMAT_WIKI => get_string("formatwiki"));
0095d5cd 428}
429
60f18531 430function format_text($text, $format=FORMAT_MOODLE, $options=NULL) {
c1d57101 431/// Given text in a variety of format codings, this function returns
432/// the text as safe HTML.
433///
434/// $text is raw text (originally from a user)
435/// $format is one of the format constants, defined above
0095d5cd 436
437 switch ($format) {
73f8658c 438 case FORMAT_HTML:
5f350e8f 439 replace_smilies($text);
73f8658c 440 return $text;
441 break;
442
6901fa79 443 case FORMAT_PLAIN:
444 $text = htmlentities($text);
5f350e8f 445 replace_smilies($text);
446 convert_urls_into_links($text);
6901fa79 447 $text = nl2br($text);
448 return $text;
449 break;
450
d342c763 451 case FORMAT_WIKI:
452 $text = wiki_to_html($text);
5f350e8f 453 replace_smilies($text);
d342c763 454 return $text;
455 break;
456
457
73f8658c 458 default: // FORMAT_MOODLE or anything else
c9dda990 459 if (!isset($options->smiley)) {
460 $options->smiley=true;
461 }
462 if (!isset($options->para)) {
1a072208 463 $options->para=true;
c9dda990 464 }
0095d5cd 465 return text_to_html($text, $options->smiley, $options->para);
466 break;
0095d5cd 467 }
468}
469
d342c763 470function format_text_email($text, $format) {
471/// Given text in a variety of format codings, this function returns
472/// the text as plain text suitable for plain email.
473///
474/// $text is raw text (originally from a user)
475/// $format is one of the format constants, defined above
476
477 switch ($format) {
478
479 case FORMAT_PLAIN:
480 return $text;
481 break;
482
483 case FORMAT_WIKI:
484 $text = wiki_to_html($text);
485 return strip_tags($text);
486 break;
487
488 default: // FORMAT_MOODLE or anything else
489 // Need to add something in here to create a text-friendly way of presenting URLs
490 return strip_tags($text);
491 break;
492 }
493}
0095d5cd 494
495function clean_text($text, $format) {
c1d57101 496/// Given raw text (eg typed in by a user), this function cleans it up
497/// and removes any nasty tags that could mess up Moodle pages.
b7a3cf49 498
3fe3851d 499 global $JAVASCRIPT_TAGS, $ALLOWED_TAGS;
500
d342c763 501 switch ($format) {
0095d5cd 502 case FORMAT_MOODLE:
0095d5cd 503 case FORMAT_HTML:
d342c763 504 case FORMAT_WIKI:
3fe3851d 505 $text = strip_tags($text, $ALLOWED_TAGS);
506 foreach ($JAVASCRIPT_TAGS as $tag) {
507 $text = stri_replace($tag, "", $text);
508 }
509 return $text;
6901fa79 510
511 case FORMAT_PLAIN:
512 return $text;
0095d5cd 513 }
b7a3cf49 514}
f9903ed0 515
5f350e8f 516function replace_smilies(&$text) {
c1d57101 517/// Replaces all known smileys in the text with image equivalents
2ea9027b 518 global $CFG;
c1d57101 519
617778f2 520 static $runonce = false;
69081931 521 static $e = array();
522 static $img = array();
617778f2 523 static $emoticons = array(
2ea9027b 524 ':-)' => 'smiley.gif',
525 ':)' => 'smiley.gif',
526 ':-D' => 'biggrin.gif',
527 ';-)' => 'wink.gif',
528 ':-/' => 'mixed.gif',
529 'V-.' => 'thoughtful.gif',
530 ':-P' => 'tongueout.gif',
531 'B-)' => 'cool.gif',
532 '^-)' => 'approve.gif',
533 '8-)' => 'wideeyes.gif',
534 ':o)' => 'clown.gif',
535 ':-(' => 'sad.gif',
536 ':(' => 'sad.gif',
537 '8-.' => 'shy.gif',
538 ':-I' => 'blush.gif',
539 ':-X' => 'kiss.gif',
540 '8-o' => 'surprise.gif',
541 'P-|' => 'blackeye.gif',
542 '8-[' => 'angry.gif',
543 'xx-P' => 'dead.gif',
544 '|-.' => 'sleepy.gif',
545 '}-]' => 'evil.gif',
546 );
547
01d79966 548 if ($runonce == false){
617778f2 549 foreach ($emoticons as $emoticon => $image){
69081931 550 $e[] = $emoticon;
01d79966 551 $img[] = "<img alt=\"$emoticon\" width=15 height=15 src=\"$CFG->wwwroot/pix/s/$image\">";
617778f2 552 }
553 $runonce = true;
c0f728ba 554 }
b7a3cf49 555
5f350e8f 556 $text = str_replace($e, $img, $text);
1a072208 557}
0095d5cd 558
909f539d 559function text_to_html($text, $smiley=true, $para=true) {
c1d57101 560/// Given plain text, makes it into HTML as nicely as possible.
561/// May contain HTML tags already
f9903ed0 562
c1d57101 563/// Remove any whitespace that may be between HTML tags
7b3be1b1 564 $text = eregi_replace(">([[:space:]]+)<", "><", $text);
565
c1d57101 566/// Remove any returns that precede or follow HTML tags
0eae8049 567 $text = eregi_replace("([\n\r])<", " <", $text);
568 $text = eregi_replace(">([\n\r])", "> ", $text);
7b3be1b1 569
5f350e8f 570 convert_urls_into_links($text);
f9903ed0 571
c1d57101 572/// Make returns into HTML newlines.
f9903ed0 573 $text = nl2br($text);
574
c1d57101 575/// Turn smileys into images.
d69cb7f4 576 if ($smiley) {
5f350e8f 577 replace_smilies($text);
d69cb7f4 578 }
f9903ed0 579
c1d57101 580/// Wrap the whole thing in a paragraph tag if required
909f539d 581 if ($para) {
01d79966 582 return "<p>".$text."</p>";
909f539d 583 } else {
584 return $text;
585 }
f9903ed0 586}
587
3e9ca9fb 588function wiki_to_html($text) {
01d79966 589/// Given Wiki formatted text, make it into XHTML using external function
3e9ca9fb 590
01d79966 591 require_once('wiki.php');
3e9ca9fb 592
01d79966 593 $wiki = new Wiki;
594 return $wiki->format($text);
3e9ca9fb 595}
596
5f350e8f 597function convert_urls_into_links(&$text) {
598/// Given some text, it converts any URLs it finds into HTML links.
599
600/// Make lone URLs into links. eg http://moodle.com/
601 $text = eregi_replace("([[:space:]]|^|\(|\[|\<)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
602 "\\1<a href=\"\\2://\\3\\4\" TARGET=\"newpage\">\\2://\\3\\4</a>", $text);
603
604/// eg www.moodle.com
605 $text = eregi_replace("([[:space:]]|^|\(|\[|\<)www\.([^[:space:]]*)([[:alnum:]#?/&=])",
606 "\\1<a href=\"http://www.\\2\\3\" TARGET=\"newpage\">www.\\2\\3</a>", $text);
607}
608
5af78ed2 609function highlight($needle, $haystack) {
c1d57101 610/// This function will highlight instances of $needle in $haystack
5af78ed2 611
612 $parts = explode(strtolower($needle), strtolower($haystack));
613
614 $pos = 0;
615
616 foreach ($parts as $key => $part) {
617 $parts[$key] = substr($haystack, $pos, strlen($part));
618 $pos += strlen($part);
619
620 $parts[$key] .= "<SPAN CLASS=highlight>".substr($haystack, $pos, strlen($needle))."</SPAN>";
621 $pos += strlen($needle);
622 }
623
624 return (join('', $parts));
625}
626
f9903ed0 627
9fa49e22 628
629/// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
630
631function print_header ($title="", $heading="", $navigation="", $focus="", $meta="", $cache=true, $button="&nbsp;", $menu="") {
632// $title - appears top of window
633// $heading - appears top of page
634// $navigation - premade navigation string
635// $focus - indicates form element eg inputform.password
636// $meta - meta tags in the header
637// $cache - should this page be cacheable?
638// $button - HTML code for a button (usually for module editing)
639// $menu - HTML code for a popup menu
640 global $USER, $CFG, $THEME;
641
642 if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) {
643 $styles = $CFG->stylesheet;
644 } else {
645 $styles = "$CFG->wwwroot/theme/standard/styles.php";
646 }
647
648 if ($navigation == "home") {
649 $home = true;
650 $navigation = "";
9d378732 651 } else {
652 $home = false;
9fa49e22 653 }
654
655 if ($button == "") {
656 $button = "&nbsp;";
657 }
658
659 if (!$menu and $navigation) {
660 if (isset($USER->id)) {
107b010b 661 $menu = "<font size=2><a target=_parent href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a></font>";
9fa49e22 662 } else {
107b010b 663 $menu = "<font size=2><a target=_parent href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
9fa49e22 664 }
665 }
666
667 // Specify character set ... default is iso-8859-1 but some languages might need something else
668 // Could be optimised by carrying the charset variable around in $USER
669 if (current_language() == "en") {
107b010b 670 $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">\n$meta\n";
9fa49e22 671 } else {
107b010b 672 $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=".get_string("thischarset")."\">\n$meta\n";
9fa49e22 673 }
674
675 if ($CFG->langdir == "RTL") {
107b010b 676 $direction = " dir=\"rtl\"";
9fa49e22 677 } else {
107b010b 678 $direction = " dir=\"ltr\"";
9fa49e22 679 }
680
681 if (!$cache) { // Do everything we can to prevent clients and proxies caching
682 @header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
683 @header("Pragma: no-cache");
684 $meta .= "\n<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
685 $meta .= "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"0\">";
686 }
687
688 include ("$CFG->dirroot/theme/$CFG->theme/header.html");
689}
690
691function print_footer ($course=NULL) {
692// Can provide a course object to make the footer contain a link to
693// to the course home page, otherwise the link will go to the site home
694 global $USER, $CFG, $THEME;
695
696
697/// Course links
698 if ($course) {
699 if ($course == "home") { // special case for site home page - please do not remove
9a9a2907 700 $homelink = "<P ALIGN=center><A TITLE=\"Moodle $CFG->release ($CFG->version)\" HREF=\"http://moodle.com/\" TARGET=\"_blank\">";
9fa49e22 701 $homelink .= "<BR><IMG WIDTH=130 HEIGHT=19 SRC=\"pix/madewithmoodle2.gif\" BORDER=0></A></P>";
702 $course = get_site();
703 $homepage = true;
704 } else {
f82c2d42 705 $homelink = "<A TARGET=\"{$CFG->framename}\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>";
9fa49e22 706 }
707 } else {
f82c2d42 708 $homelink = "<A TARGET=\"{$CFG->framename}\" HREF=\"$CFG->wwwroot\">".get_string("home")."</A>";
9fa49e22 709 $course = get_site();
710 }
711
712/// User links
a282d0ff 713 $loggedinas = user_login_string($course, $USER);
714
715 include ("$CFG->dirroot/theme/$CFG->theme/footer.html");
716}
717
718
719function user_login_string($course, $user=NULL) {
720 global $USER, $CFG;
721
722 if (!$user) {
723 $user = $USER;
724 }
725
726 if (isset($user->realuser)) {
727 if ($realuser = get_record("user", "id", $user->realuser)) {
ca16eaeb 728 $realuserinfo = " [<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&return=$realuser->id\">$realuser->firstname $realuser->lastname</A>] ";
9fa49e22 729 }
9d378732 730 } else {
731 $realuserinfo = "";
9fa49e22 732 }
733
a282d0ff 734 if (isset($user->id) and $user->id) {
ca16eaeb 735 $username = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</a>";
9fa49e22 736 $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
ca16eaeb 737 " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a>)";
9fa49e22 738 } else {
739 $loggedinas = get_string("loggedinnot", "moodle").
ca16eaeb 740 " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a>)";
9fa49e22 741 }
a282d0ff 742 return $loggedinas;
9fa49e22 743}
744
745
9fa49e22 746function print_navigation ($navigation) {
747 global $CFG;
748
749 if ($navigation) {
750 if (! $site = get_site()) {
751 $site->shortname = get_string("home");;
752 }
eb347b6b 753 echo "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">$site->shortname</a> -> $navigation";
9fa49e22 754 }
755}
756
757function print_heading($text, $align="CENTER", $size=3) {
7d8f674d 758 echo "<P ALIGN=\"$align\"><FONT SIZE=\"$size\"><B>".stripslashes_safe($text)."</B></FONT></P>";
9fa49e22 759}
760
761function print_heading_with_help($text, $helppage, $module="moodle") {
762// Centered heading with attached help button (same title text)
eb347b6b 763 echo "<p align=\"center\"><font size=\"3\"><b>".stripslashes_safe($text);
9fa49e22 764 helpbutton($helppage, $text, $module);
eb347b6b 765 echo "</b></font></p>";
9fa49e22 766}
767
768function print_continue($link) {
9fa49e22 769
770 if (!$link) {
607809b3 771 $link = $_SERVER["HTTP_REFERER"];
9fa49e22 772 }
773
eb347b6b 774 print_heading("<a href=\"$link\">".get_string("continue")."</a>");
9fa49e22 775}
776
777
778function print_simple_box($message, $align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
779 print_simple_box_start($align, $width, $color, $padding, $class);
7d8f674d 780 echo stripslashes_safe($message);
9fa49e22 781 print_simple_box_end();
782}
783
784function print_simple_box_start($align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
785 global $THEME;
786
787 if ($align) {
9d378732 788 $align = "ALIGN=\"$align\"";
9fa49e22 789 }
790 if ($width) {
9d378732 791 $width = "WIDTH=\"$width\"";
9fa49e22 792 }
9d378732 793 echo "<table $align $width class=\"$class\" border=\"0\" cellpadding=\"$padding\" cellspacing=\"0\"><tr><td bgcolor=\"$color\" class=\"$class"."content\">";
9fa49e22 794}
795
796function print_simple_box_end() {
797 echo "</td></tr></table>";
798}
799
800function print_single_button($link, $options, $label="OK") {
801 echo "<FORM ACTION=\"$link\" METHOD=GET>";
802 if ($options) {
803 foreach ($options as $name => $value) {
804 echo "<INPUT TYPE=hidden NAME=\"$name\" VALUE=\"$value\">";
805 }
806 }
807 echo "<INPUT TYPE=submit VALUE=\"$label\"></FORM>";
808}
809
810function print_spacer($height=1, $width=1, $br=true) {
811 global $CFG;
812 echo "<IMG HEIGHT=\"$height\" WIDTH=\"$width\" SRC=\"$CFG->wwwroot/pix/spacer.gif\" ALT=\"\">";
813 if ($br) {
814 echo "<BR \>\n";
815 }
816}
817
818function print_file_picture($path, $courseid=0, $height="", $width="", $link="") {
819// Given the path to a picture file in a course, or a URL,
820// this function includes the picture in the page.
821 global $CFG;
822
823 if ($height) {
824 $height = "HEIGHT=\"$height\"";
825 }
826 if ($width) {
827 $width = "WIDTH=\"$width\"";
828 }
829 if ($link) {
830 echo "<A HREF=\"$link\">";
831 }
832 if (substr(strtolower($path), 0, 7) == "http://") {
833 echo "<IMG BORDER=0 $height $width SRC=\"$path\">";
834
835 } else if ($courseid) {
836 echo "<IMG BORDER=0 $height $width SRC=\"";
837 if ($CFG->slasharguments) { // Use this method if possible for better caching
838 echo "$CFG->wwwroot/file.php/$courseid/$path";
839 } else {
3f396065 840 echo "$CFG->wwwroot/file.php?file=/$courseid/$path";
9fa49e22 841 }
842 echo "\">";
843 } else {
844 echo "Error: must pass URL or course";
845 }
846 if ($link) {
847 echo "</A>";
848 }
849}
850
851function print_user_picture($userid, $courseid, $picture, $large=false, $returnstring=false, $link=true) {
852 global $CFG;
853
854 if ($link) {
855 $output = "<A HREF=\"$CFG->wwwroot/user/view.php?id=$userid&course=$courseid\">";
856 } else {
857 $output = "";
858 }
859 if ($large) {
860 $file = "f1.jpg";
861 $size = 100;
862 } else {
863 $file = "f2.jpg";
864 $size = 35;
865 }
866 if ($picture) {
867 if ($CFG->slasharguments) { // Use this method if possible for better caching
868 $output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
869 } else {
870 $output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php?file=/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
871 }
872 } else {
873 $output .= "<IMG SRC=\"$CFG->wwwroot/user/default/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
874 }
875 if ($link) {
876 $output .= "</A>";
877 }
878
879 if ($returnstring) {
880 return $output;
881 } else {
882 echo $output;
883 }
884}
885
886function print_table($table) {
887// Prints a nicely formatted table.
888// $table is an object with several properties.
889// $table->head is an array of heading names.
890// $table->align is an array of column alignments
891// $table->size is an array of column sizes
892// $table->data[] is an array of arrays containing the data.
893// $table->width is an percentage of the page
894// $table->cellpadding padding on each cell
895// $table->cellspacing spacing between cells
896
897 if (isset($table->align)) {
898 foreach ($table->align as $key => $aa) {
899 if ($aa) {
900 $align[$key] = " ALIGN=\"$aa\"";
901 } else {
902 $align[$key] = "";
903 }
904 }
905 }
906 if (isset($table->size)) {
907 foreach ($table->size as $key => $ss) {
908 if ($ss) {
909 $size[$key] = " WIDTH=\"$ss\"";
910 } else {
911 $size[$key] = "";
912 }
913 }
914 }
915
9d378732 916 if (empty($table->width)) {
9fa49e22 917 $table->width = "80%";
918 }
919
9d378732 920 if (empty($table->cellpadding)) {
9fa49e22 921 $table->cellpadding = "5";
922 }
923
9d378732 924 if (empty($table->cellspacing)) {
9fa49e22 925 $table->cellspacing = "1";
926 }
927
928 print_simple_box_start("CENTER", "$table->width", "#FFFFFF", 0);
929 echo "<TABLE WIDTH=100% BORDER=0 valign=top align=center ";
930 echo " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"generaltable\">\n";
931
b79f41cd 932 if (!empty($table->head)) {
9fa49e22 933 echo "<TR>";
934 foreach ($table->head as $key => $heading) {
9d378732 935 if (!isset($size[$key])) {
936 $size[$key] = "";
937 }
938 if (!isset($align[$key])) {
939 $align[$key] = "";
940 }
9fa49e22 941 echo "<TH VALIGN=top ".$align[$key].$size[$key]." NOWRAP class=\"generaltableheader\">$heading</TH>";
942 }
943 echo "</TR>\n";
944 }
945
946 foreach ($table->data as $row) {
947 echo "<TR VALIGN=TOP>";
948 foreach ($row as $key => $item) {
9d378732 949 if (!isset($size[$key])) {
950 $size[$key] = "";
951 }
952 if (!isset($align[$key])) {
953 $align[$key] = "";
954 }
9fa49e22 955 echo "<TD ".$align[$key].$size[$key]." class=\"generaltablecell\">$item</TD>";
956 }
957 echo "</TR>\n";
958 }
959 echo "</TABLE>\n";
960 print_simple_box_end();
961
962 return true;
963}
964
965function print_editing_switch($courseid) {
966 global $CFG, $USER;
967
968 if (isteacher($courseid)) {
969 if ($USER->editing) {
970 echo "<A HREF=\"$CFG->wwwroot/course/view.php?id=$courseid&edit=off\">Turn editing off</A>";
971 } else {
972 echo "<A HREF=\"$CFG->wwwroot/course/view.php?id=$courseid&edit=on\">Turn editing on</A>";
973 }
974 }
975}
976
977function print_textarea($richedit, $rows, $cols, $width, $height, $name, $value="") {
7d8f674d 978/// Prints a richtext field or a normal textarea
9fa49e22 979 global $CFG, $THEME;
980
981 if ($richedit) {
982 echo "<object id=richedit style=\"BACKGROUND-COLOR: buttonface\"";
983 echo " data=\"$CFG->wwwroot/lib/rte/richedit.html\"";
984 echo " width=\"$width\" height=\"$height\" ";
985 echo " type=\"text/x-scriptlet\" VIEWASTEXT></object>\n";
986 echo "<TEXTAREA style=\"display:none\" NAME=\"$name\" ROWS=1 COLS=1>";
987 p($value);
988 echo "</TEXTAREA>\n";
989 } else {
990 echo "<TEXTAREA name=\"$name\" rows=\"$rows\" cols=\"$cols\" wrap=virtual>";
991 p($value);
992 echo "</TEXTAREA>\n";
993 }
994}
995
996function print_richedit_javascript($form, $name, $source="no") {
997 echo "<SCRIPT language=\"JavaScript\" event=\"onload\" for=\"window\">\n";
998 echo " document.richedit.options = \"history=no;source=$source\";";
999 echo " document.richedit.docHtml = $form.$name.innerText;";
1000 echo "</SCRIPT>";
1001}
1002
1003
1004function update_course_icon($courseid) {
1005// Used to be an icon, but it's now a simple form button
1006 global $CFG, $USER;
1007
1008 if (isteacher($courseid)) {
9c9f7d77 1009 if (!empty($USER->editing)) {
9fa49e22 1010 $string = get_string("turneditingoff");
1011 $edit = "off";
1012 } else {
1013 $string = get_string("turneditingon");
1014 $edit = "on";
1015 }
1016 return "<FORM TARGET=_parent METHOD=GET ACTION=\"$CFG->wwwroot/course/view.php\">".
1017 "<INPUT TYPE=hidden NAME=id VALUE=\"$courseid\">".
1018 "<INPUT TYPE=hidden NAME=edit VALUE=\"$edit\">".
1019 "<INPUT TYPE=submit VALUE=\"$string\"></FORM>";
1020 }
1021}
1022
1023function update_module_button($moduleid, $courseid, $string) {
1024// Prints the editing button on a module "view" page
1025 global $CFG;
1026
1027 if (isteacher($courseid)) {
1028 $string = get_string("updatethis", "", $string);
1029 return "<FORM TARGET=_parent METHOD=GET ACTION=\"$CFG->wwwroot/course/mod.php\">".
1030 "<INPUT TYPE=hidden NAME=update VALUE=\"$moduleid\">".
1031 "<INPUT TYPE=hidden NAME=return VALUE=\"true\">".
1032 "<INPUT TYPE=submit VALUE=\"$string\"></FORM>";
1033 }
1034}
1035
1036
1037function navmenu($course, $cm=NULL) {
1038// Given a course and a (current) coursemodule
1039// This function returns a small popup menu with all the
1040// course activity modules in it, as a navigation menu
1041// The data is taken from the serialised array stored in
1042// the course record
1043
1044 global $CFG;
1045
1046 if ($cm) {
1047 $cm = $cm->id;
1048 }
1049
1050 if ($course->format == 'weeks') {
1051 $strsection = get_string("week");
1052 } else {
1053 $strsection = get_string("topic");
1054 }
1055
1056 if (!$modinfo = unserialize($course->modinfo)) {
1057 return "";
1058 }
1059 $section = -1;
1060 $selected = "";
1061 foreach ($modinfo as $mod) {
1062 if ($mod->section > 0 and $section <> $mod->section) {
1063 $menu[] = "-------------- $strsection $mod->section --------------";
1064 }
1065 $section = $mod->section;
cf055081 1066 //Only add visible or teacher mods to jumpmenu
1067 if ($mod->visible or isteacher($course->id)) {
1068 $url = "$mod->mod/view.php?id=$mod->cm";
1069 if ($cm == $mod->cm) {
1070 $selected = $url;
1071 }
1072 $mod->name = urldecode($mod->name);
1073 if (strlen($mod->name) > 55) {
1074 $mod->name = substr($mod->name, 0, 50)."...";
1075 }
2a409368 1076 if (!$mod->visible) {
1077 $mod->name = "(".$mod->name.")";
1078 }
cf055081 1079 $menu[$url] = $mod->name;
9fa49e22 1080 }
9fa49e22 1081 }
1082
1083 return popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, get_string("jumpto"), "", "", true);
1084}
1085
1086
1087
1088function print_date_selector($day, $month, $year, $currenttime=0) {
1089// Currenttime is a default timestamp in GMT
1090// Prints form items with the names $day, $month and $year
1091
1092 if (!$currenttime) {
1093 $currenttime = time();
1094 }
1095 $currentdate = usergetdate($currenttime);
1096
1097 for ($i=1; $i<=31; $i++) {
1098 $days[$i] = "$i";
1099 }
1100 for ($i=1; $i<=12; $i++) {
39e018b3 1101 $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
9fa49e22 1102 }
1103 for ($i=2000; $i<=2010; $i++) {
1104 $years[$i] = $i;
1105 }
47f1da80 1106 choose_from_menu($days, $day, $currentdate['mday'], "");
1107 choose_from_menu($months, $month, $currentdate['mon'], "");
1108 choose_from_menu($years, $year, $currentdate['year'], "");
9fa49e22 1109}
1110
1111function print_time_selector($hour, $minute, $currenttime=0) {
1112// Currenttime is a default timestamp in GMT
1113// Prints form items with the names $hour and $minute
1114
1115 if (!$currenttime) {
1116 $currenttime = time();
1117 }
1118 $currentdate = usergetdate($currenttime);
1119 for ($i=0; $i<=23; $i++) {
1120 $hours[$i] = sprintf("%02d",$i);
1121 }
1122 for ($i=0; $i<=59; $i++) {
1123 $minutes[$i] = sprintf("%02d",$i);
1124 }
47f1da80 1125 choose_from_menu($hours, $hour, $currentdate['hours'], "");
1126 choose_from_menu($minutes, $minute, $currentdate['minutes'], "");
9fa49e22 1127}
1128
1129function error ($message, $link="") {
1130 global $CFG, $SESSION;
1131
1132 print_header(get_string("error"));
1133 echo "<BR>";
1134 print_simple_box($message, "center", "", "#FFBBBB");
1135
1136 if (!$link) {
1137 if ( !empty($SESSION->fromurl) ) {
1138 $link = "$SESSION->fromurl";
1139 unset($SESSION->fromurl);
9fa49e22 1140 } else {
1141 $link = "$CFG->wwwroot";
1142 }
1143 }
1144 print_continue($link);
1145 print_footer();
1146 die;
1147}
1148
1149function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $text="") {
1150 // $page = the keyword that defines a help page
1151 // $title = the title of links, rollover tips, alt tags etc
1152 // $module = which module is the page defined in
1153 // $image = use a help image for the link? (true/false/"both")
1154 // $text = if defined then this text is used in the page, and
1155 // the $page variable is ignored.
dc0dc7d5 1156 global $CFG, $THEME;
9fa49e22 1157
1158 if ($module == "") {
1159 $module = "moodle";
1160 }
1161
dc0dc7d5 1162 if (empty($THEME->custompix)) {
1163 $icon = "$CFG->wwwroot/pix/help.gif";
1164 } else {
1165 $icon = "$CFG->wwwroot/theme/$CFG->theme/pix/help.gif";
1166 }
1167
9fa49e22 1168 if ($image) {
1169 if ($linktext) {
dc0dc7d5 1170 $linkobject = "$title<img align=\"absmiddle\" border=0 height=17 width=22 alt=\"\" src=\"$icon\">";
9fa49e22 1171 } else {
dc0dc7d5 1172 $linkobject = "<img align=\"absmiddle\" border=0 height=17 width=22 alt=\"$title\" src=\"$icon\">";
9fa49e22 1173 }
1174 } else {
1175 $linkobject = $title;
1176 }
1177 if ($text) {
1178 $url = "/help.php?module=$module&text=".htmlentities(urlencode($text));
1179 } else {
1180 $url = "/help.php?module=$module&file=$page.html";
1181 }
1182 link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title);
1183}
1184
1185function notice ($message, $link="") {
750ab759 1186 global $CFG, $THEME;
9fa49e22 1187
1188 if (!$link) {
750ab759 1189 if (!empty($_SERVER["HTTP_REFERER"])) {
1190 $link = $_SERVER["HTTP_REFERER"];
1191 } else {
1192 $link = $CFG->wwwroot;
1193 }
9fa49e22 1194 }
1195
01d79966 1196 echo "<br />";
11a876e1 1197 print_simple_box($message, "center", "50%", "$THEME->cellheading", "20", "noticebox");
eb347b6b 1198 print_heading("<a href=\"$link\">".get_string("continue")."</a>");
9fa49e22 1199 print_footer(get_site());
1200 die;
1201}
1202
1203function notice_yesno ($message, $linkyes, $linkno) {
1204 global $THEME;
1205
eb347b6b 1206 print_simple_box_start("center", "60%", "$THEME->cellheading");
1207 echo "<p align=center><font size=3>$message</font></p>";
1208 echo "<p align=center><font size=3><b>";
1209 echo "<a href=\"$linkyes\">".get_string("yes")."</a>";
9fa49e22 1210 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
eb347b6b 1211 echo "<a href=\"$linkno\">".get_string("no")."</a>";
1212 echo "</b></font></p>";
9fa49e22 1213 print_simple_box_end();
1214}
1215
1216function redirect($url, $message="", $delay=0) {
1217// Uses META tags to redirect the user, after printing a notice
1218
c9082a8c 1219 if (empty($message)) {
1220 echo "<META HTTP-EQUIV='Refresh' CONTENT='$delay; URL=$url'>";
1221 } else {
1222 if (! $delay) {
1223 $delay = 3; // There's no point having a message with no delay
1224 }
1225 echo "<META HTTP-EQUIV='Refresh' CONTENT='$delay; URL=$url'>";
9fa49e22 1226 print_header();
1227 echo "<CENTER>";
1228 echo "<P>$message</P>";
1229 echo "<P>( <A HREF=\"$url\">".get_string("continue")."</A> )</P>";
1230 echo "</CENTER>";
1231 }
1232 die;
1233}
1234
99988d1a 1235function notify ($message, $color="red", $align="center") {
1236 echo "<p align=\"$align\"><b><font color=\"$color\">$message</font></b></p>\n";
9fa49e22 1237}
1238
1239
9d5b689c 1240// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
f9903ed0 1241?>