. require_once("../inc/db_ops.inc"); require_once("../inc/util.inc"); require_once("../project/project.inc"); // TODO: get rid of the following. use style sheets define("TD", ""); define("TD2", ""); define("TD3", ""); define("TABLE", ""); define("TABLE2", "
"); function admin_page_head($title) { $stylesheet = URL_BASE.STYLESHEET; echo "$title

".PROJECT.": $title

"; } function admin_page_tail() { echo "

Back to Main admin page | "; $user = get_logged_in_user_ops(); if ($user) { echo "logged in as $user->name. Log out"; } else { echo "Log in"; } echo "
"; } // TODO: get rid of all the following 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\n\n"; } function c_row2($color, $x, $y) { echo "\n"; } function show_profile_link_ops($user) { if ($user->has_profile) { row2("Profile", "id\">View" ); } } // initialize database connection with username & password from // command line instead of config.xml // function db_init_cli() { $config = get_config(); $db_name = parse_config($config, ""); $host = parse_config($config, ""); if ($host == null) { $host = "localhost"; } $in = fopen("php://stdin","r"); print "Database username for $db_name@$host: "; $user = rtrim(fgets($in, 80)); print "Database password for $db_name@host: "; $pass = rtrim(fgets($in, 80)); $retval = mysql_pconnect($host, $user, $pass); if (!$retval) { return 1; } if (!mysql_select_db($db_name)) { return 2; } return 0; } function print_login_form_ops($next_url='') { if ($next_url == '') $next_url = $_SERVER['REQUEST_URI']; start_table(); echo "
"; row2("Email", ""); row2("Password", ""); row2("", ""); end_table(); } function get_logged_in_user_ops() { global $g_logged_in_user; if ($g_logged_in_user) return $g_logged_in_user; $authenticator = null; if (isset($_COOKIE['auth'])) $authenticator = $_COOKIE['auth']; $authenticator = BoincDb::escape_string($authenticator); if ($authenticator) { $g_logged_in_user = BoincUser::lookup("authenticator='$authenticator'"); } return $g_logged_in_user; } ////////// functions for access control of admin web pages ///////////// // allow access only if logged in as user in a given set // function auth_ops_userid($admin_user_ids) { $user = get_logged_in_user_ops(); if (!$user) { admin_page_head("Log in"); echo "You must log in to performance admin functions.

\n"; print_login_form_ops(); admin_page_tail(); exit; } else if (!in_array($user->id, $admin_user_ids)) { admin_page_head("Log in"); echo " You must be logged in as an admin to perform admin functions.

Log out "; admin_page_tail(); exit; } } // allow access only to users with ADMIN/DEV flags in forum prefs. // If you use this, make sure you know who has these privileges // function auth_ops_privilege() { $user = get_logged_in_user_ops(); if (!$user) { admin_page_head("Log in"); echo "You must log in to performance admin functions.

\n"; print_login_form_ops(); admin_page_tail(); exit; } BoincForumPrefs::lookup($user); if ($user->prefs->privilege(S_ADMIN) || $user->prefs->privilege(S_DEV)) { return; } error_page("Access denied"); } // if project hasn't specified a policy in project.inc, // and no .htaccess, don't allow access // if (!function_exists('auth_ops')) { function auth_ops() { if (!file_exists(".htaccess")) { error_page(" You must protect the admin interface with either a .htaccess file or an auto_ops() function.

See how here" ); } } } function error_page_ops($msg) { admin_page_head("Unable to handle request"); echo $msg; admin_page_tail(); exit; } if (isset($cli_only)) { if (array_key_exists("SERVER_PORT", $_SERVER)) { die("This script is intended to be run from the command line, not from the web server." ); } } if (!isset($skip_auth_ops) && array_key_exists("SERVER_PORT", $_SERVER)) { auth_ops(); } $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?>

$x$y
$x$y