From e43d6f3cdf2d4df747b95e5bae335c8276dd6bea Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 17 Jul 2003 23:54:23 +0000 Subject: [PATCH] Renamed from util.inc to distinguish it from util.inc in html_user/ svn path=/trunk/boinc/; revision=1723 --- html/ops/util_ops.inc | 145 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 html/ops/util_ops.inc diff --git a/html/ops/util_ops.inc b/html/ops/util_ops.inc new file mode 100644 index 0000000000..86b34f2ec3 --- /dev/null +++ b/html/ops/util_ops.inc @@ -0,0 +1,145 @@ +"); +define("SM_FONT", ""); + +define("TD", ""); +define("TD2", ""); +define("TD3", ""); + +define("TABLE", ""); +define("TABLE2", "
"); + +define("TITLE_COLOR", " bgcolor=000000 "); +define("TITLE_FONT", " "); +define("BODY_COLOR", " bgcolor=ffffff "); +define("NOLOGIN", "Not logged in. Click here to login.\n"); +define("BADPASS", "The password you entered is incorrect. Click the Back button on your browser to re-enter your password or try again later."); +define("DIFFPASS", "You've typed two different passwords. Click the Back button on your browser to edit your information, making sure you type the same password in both password fields."); +define("PROJECT", "Sample project"); + +function get_user_from_cookie() { + $auth = ""; + $c = getenv("HTTP_COOKIE"); + $d = str_replace("; ", "&", $c); + parse_str($d); + if ($auth) return lookup_user_auth($auth); + return NULL; +} + +function show_login($user) { + if ($user) { + printf("Logged in as %s.\n", $user->name); + printf("
Log in as someone else.\n"); + } else { + echo NOLOGIN; + } +} + +function page_head($title) { + echo "$title\n"; + echo TABLE . "
" . TITLE_FONT . "".PROJECT.": $title
\n"; +} + +function page_tail() { + echo "
Main admin page \n"; +} + +function date_str($when) { + return date("g:i A, l M j", $when); +} + +function time_str($x) { + if ($x == 0) return "---"; + return strftime("%T %b %e, %Y", $x); +} + +function start_table() { + echo "\n"; +} + +function end_table() { + echo "
\n"; +} + +function print_checkbox($text,$name,$checked) { + echo "" + . "$text\n" + . "

\n"; +} + +function print_radio_button($text,$name,$value,$checked) { + echo "" + . "$text\n" + . "
\n"; +} + +function print_text_field($text,$name,$value) { + echo "$text \n" + . "

\n"; +} + +function row($x, $y) { + echo "\n$x\n$y\n\n"; +} + +function row2($x, $y) { + echo "$x$y\n"; +} + +function row3($x, $y, $z) { + echo "$x$y$z\n"; +} + +function row4($xx, $xy, $yx, $yy) { + echo "$xx$xy" + . "$yx$yy\n"; +} + +function random_string() { + return md5(uniqid(rand())); +} + +function print_country_select() { + PassThru("country_select"); +} + +// look for an element in some XML text +// +function parse_element($xml, $tag) { + $element = null; + $x = strstr($xml, $tag); + if ($x) { + $y = substr($x, strlen($tag)); + $n = strpos($y, "<"); + if ($n) { + $element = substr($y, 0, $n); + } + } + return $element; +} + +// look for a particular element in the config.xml file +// +function parse_config($tag) { + $element = null; + $fp = fopen("../config.xml", "r"); + while (1) { + $buf = fgets($fp, 1024); + if ($buf == null) break; + $element = parse_element($buf, $tag); + if ($element) break; + } + fclose($fp); + return $element; +} + +?>