- web: don't require login for show_user.php

- web: add app selection to example project-specific prefs
    (commented out by default)
- web: in prefs, flag too-low numeric values as errors,
    rather than just setting to min value
- web: fix bug when add new venue from "columns" view

svn path=/trunk/boinc/; revision=14442
This commit is contained in:
David Anderson 2007-12-24 21:34:21 +00:00
parent bcf062975c
commit f125e7e2de
8 changed files with 194 additions and 71 deletions

View File

@ -12498,3 +12498,25 @@ David 24 Dec 2007
team_export.php
py/Boinc/
setup_project.py
David 24 Dec 2007
- web: don't require login for show_user.php
- web: add app selection to example project-specific prefs
(commented out by default)
- web: in prefs, flag too-low numeric values as errors,
rather than just setting to min value
- web: fix bug when add new venue from "columns" view
html/
inc/
prefs.inc
uotd.inc
util.inc
ops/
sample_server_status.php
project.sample/
project_specific_prefs.php
user/
show_user.php
sched/
sched_send.C

View File

@ -122,7 +122,7 @@ define("ALLOW_BETA_WORK",
// These texts are used in multiple places in prefs_edit.php and add_venue.php
define("PREFS_FORM_DESC1", "These preferences apply to all the BOINC projects in which you participate.<br><br>");
define("PREFS_FORM_ERROR_DESC", "<b>Unable to update preferences.</b> Some values (marked in red below) were out of range or not numeric.<br><br>");
define("PREFS_FORM_ERROR_DESC", "<b>Unable to update preferences.</b> The values marked in red below were out of range or not numeric.<br><br>");
global $text;
global $parse_result;
@ -613,7 +613,7 @@ function row_field($value, $type) {
function row_links($subset, $prefs) {
global $g_logged_in_user;
$tokens = url_tokens($g_logged_in_user->authenticator);
$pre_add = "<a href=add_venue.php?$venue=";
$pre_add = "<a href=add_venue.php?venue=";
$pre_edit = "<a href=prefs_edit.php?venue=";
$pre_remove = "<a href=prefs_remove.php?venue=";
$post_add = "&subset=$subset&cols=1$tokens>Add</a>";

View File

@ -16,13 +16,10 @@ function uotd_thumbnail($profile, $user) {
// show UOTD in a small box
//
function show_uotd() {
$profile = get_current_uotd();
if ($profile) {
$user = lookup_user_id($profile->userid);
echo user_links($user)."<br>";
echo sub_sentence(strip_tags(output_transform($profile->response1)), ' ', 150, true);
}
function show_uotd($profile) {
$user = lookup_user_id($profile->userid);
echo user_links($user)."<br>";
echo sub_sentence(strip_tags(output_transform($profile->response1)), ' ', 150, true);
}
// return the last UOTD profile, or null

View File

@ -700,7 +700,8 @@ function link_with_GET_variables($text, $baseurl, $variable_name, $variable_valu
// @param string &$value reference to the value that should be verified
// @param double $low the lowest number of value if verified
// @param double $high the highest number of value if verified
// @return bool true if $value is numeric and within the defined borders, false if $value is not numeric, no changes were made in this case
// @return bool true if $value is numeric and within the defined borders,
// false if $value is not numeric, no changes were made in this case
//
function verify_numeric(&$value, $low, $high = false) {
$number = trim($value);
@ -714,9 +715,12 @@ function verify_numeric(&$value, $low, $high = false) {
// the supplied value contains alphabetic characters
if (!is_numeric($number)) return false;
if ($number < $low) $number = $low;
//if ($number < $low) $number = $low;
if ($number < $low) return false;
if ($high) {
if ($number > $high) $number = $high;
//if ($number > $high) $number = $high;
if ($number > $high) return false;
}
$value = (double)$number;
return true;

View File

@ -227,14 +227,20 @@ show_status($sched_host, "scheduler", $sched_running);
$cursor = 0;
while ($thisxml = trim(parse_next_element($config_xml,"<daemon>",$cursor))) {
$host = parse_element($thisxml,"<host>");
if ($host == "") { $host = $project_host; }
if ($host == "") {
$host = $project_host;
}
$cmd = parse_element($thisxml,"<cmd>");
list($ncmd) = explode(" ",$cmd);
$log = parse_element($thisxml,"<output>");
if (!$log) { $log = $ncmd . ".log"; }
if (!$log) {
$log = $ncmd . ".log";
}
list($nlog) = explode(".log",$log);
$pid = parse_element($thisxml,"<pid_file>");
if (!$pid) { $pid = $ncmd . ".pid"; }
if (!$pid) {
$pid = $ncmd . ".pid";
}
$disabled = parse_element($thisxml,"<disabled>");
show_daemon_status($host, $nlog, $ncmd, $disabled);
}

View File

@ -1,85 +1,178 @@
<?php
// Place your version in project_specific/project_specific_prefs.inc
// Sample code for project-specific preferences.
// These prefs may include:
//
// - preferences for your application graphics
// - application selection (i.e. if you have muliple apps,
// let user choose among them)
// Functions to display and edit project-specific prefs go here
// These prefs are represented in three ways:
// - as an XML document (stored in the DB in this form)
// - as a PHP structure
// - as a set of HTTP GET form variables
// The code here is a sample. Projects must supply their own.
// This file exports the following functions
// (called from html/inc/prefs.inc):
//
// project_specific_prefs_default()
// Returns XML for default preferences
// project_specific_prefs_parse($xml)
// Parse prefs as XML, return prefs as PHP structure
// project_specific_prefs_show($prefs, $columns=false)
// Show prefs as HTML (non-editable)
// project_specific_prefs_edit($prefs, $error)
// Show prefs as HTML, editable.
// $error is a struct indicating which values were erroneous
// (value X is erroneous if $error->X is set)
// project_specific_prefs_parse_form(&$error)
// Parse form variables into XML, and return it.
// Also error-check values, and return errors in $errors->*
// Place your version in html/project_specific/project_specific_prefs.inc
function option($name, $val) {
if ($name == $val) {
$x = "selected";
} else {
$x = "";
}
$x = ($name == $val) ? "selected" : "";
return "<option name='$name' $x>$name\n";
}
define('COLOR_DESC', 'Color scheme for graphics');
define('FRAME_RATE_DESC', 'Max frames/second for graphics<br><span class=note>0 or blank if no limit</span>');
define('APP_SELECT_DESC', 'Run only the selected applications');
// The following array is for app filtering; uncomment if you want it.
// Note: in this implementation, if a user selects all apps,
// no <app_id> elements are included in their prefs,
// which means that if the project adds a new app such users will run it also.
//
if (false) {
$app_array = array(
array(1, "Application one"),
array(2, "Application two"),
);
} else {
$app_array = null;
}
function selected_app_text($prefs) {
global $app_array;
if (isset($prefs->app_ids)) {
$x = "";
foreach ($app_array as $app) {
$app_id = $app[0];
$app_name = $app[1];
if (in_array($app_id, $prefs->app_ids)) {
$x .= "$app_name: yes<br>";
} else {
$x .= "$app_name: no<br>";
}
}
} else {
$x = "(all applications)";
}
return $x;
}
function project_specific_prefs_default() {
return "
<color_scheme>Tahiti Sunset</color_scheme>
<max_frames_sec>100</max_frames_sec>
<max_frames_sec>30</max_frames_sec>
";
}
// given struct, show form for editing
// $error is a struct indicating which values were erroneous
// (value X is erroneous if $error->X is set)
//
function project_specific_prefs_edit($prefs, $error=false) {
global $app_array;
$x = $prefs->color_scheme;
$y = "<select name=color_scheme>
".option("Tahiti Sunset", $x)
.option("Desert Sands", $x)."
</select>
";
row2("Color scheme", $y);
row2(COLOR_DESC, $y);
$y = "<input size=5 name=max_frames_sec value='$prefs->max_frames_sec'>";
row2("Max frames/sec", $y, isset($error->max_frames_sec));
}
// Parse form vars, return XML version of project-specific prefs
// Also set $error, store the error values (see above)
//
function project_specific_prefs_parse_form(&$error) {
$color_scheme = $_GET["color_scheme"];
$max_frames_sec = $_GET["max_frames_sec"];
// add and modify this line for other user
// editable values that should be validated
//
if (!verify_numeric($max_frames_sec, 0)) $error->max_frames_sec = true;
// Please look at util.inc for further information regarding:
// function verify_numeric(&$value, $low, $high = false)
return "<color_scheme>$color_scheme</color_scheme>
<max_frames_sec>$max_frames_sec</max_frames_sec>
";
}
// show non-editable version of prefs
//
function project_specific_prefs_show($prefs, $columns=false) {
// Please add your prefs-values for both views!!
//
if ($columns) {
// This is used if columns-view is enabled
row_defs("Color scheme","color_scheme", "", "", $prefs);
row_defs("Max frames/sec", "max_frames_sec", "", "", $prefs);
} else {
// This is used if normal-view is enabled
row2("Color scheme", $prefs->color_scheme);
row2("Max frames/sec", $prefs->max_frames_sec);
row2(FRAME_RATE_DESC, $y, isset($error->max_frames_sec));
if ($app_array) {
$x = "";
foreach ($app_array as $app) {
$app_id = $app[0];
$app_name = $app[1];
if (isset($prefs->app_ids)) {
$present = in_array($app_id, $prefs->app_ids);
} else {
$present = true;
}
$checked = $present?"checked":"";
$x .= "<input type=checkbox name=app_id_$app_id $checked> $app_name<br>";
}
row2(APP_SELECT_DESC, $x);
}
}
function project_specific_prefs_parse_form(&$error) {
global $app_array;
$color_scheme = $_GET["color_scheme"];
$max_frames_sec = $_GET["max_frames_sec"];
// Error-check preferences
//
if (!verify_numeric($max_frames_sec, 0)) $error->max_frames_sec = true;
$x = "<color_scheme>$color_scheme</color_scheme>
<max_frames_sec>$max_frames_sec</max_frames_sec>
";
if ($app_array) {
$y = "";
$some_unchecked = false;
foreach ($app_array as $app) {
$app_id = $app[0];
$present = isset($_GET["app_id_$app_id"]);
if ($present) {
$x .= "<app_id>$app_id</app_id>\n";
} else {
$some_unchecked = true;
}
}
if ($some_unchecked) {
$x .= $y;
}
}
return $x;
}
function project_specific_prefs_show($prefs, $columns=false) {
global $app_array;
if ($columns) {
row_defs(COLOR_DESC,"color_scheme", "", "", $prefs);
row_defs(FRAME_RATE_DESC, "max_frames_sec", "", "", $prefs);
if ($app_array) {
$prefs->app_id_text = selected_app_text($prefs);
if ($prefs->home) $prefs->home->app_id_text = selected_app_text($prefs->home);
if ($prefs->school) $prefs->school->app_id_text = selected_app_text($prefs->school);
if ($prefs->work) $prefs->work->app_id_text = selected_app_text($prefs->work);
row_defs(APP_SELECT_DESC, "app_id_text", "", "", $prefs);
}
} else {
row2(COLOR_DESC, $prefs->color_scheme);
row2(FRAME_RATE_DESC, $prefs->max_frames_sec);
if ($app_array) {
row2(APP_SELECT_DESC, selected_app_text($prefs));
}
}
}
// parse XML, fill in struct
//
function project_specific_prefs_parse($prefs_xml) {
$prefs->color_scheme = parse_element($prefs_xml, "<color_scheme>");
$prefs->max_frames_sec = parse_element($prefs_xml, "<max_frames_sec>");
$cursor = 0;
while ($thisxml = parse_next_element($prefs_xml, "<app_id>", $cursor)) {
if (is_numeric($thisxml)) {
$n = (int) $thisxml;
$prefs->app_ids[] = $n;
}
}
return $prefs;
}

View File

@ -66,7 +66,7 @@ if ($format=="xml"){
error_page("No such user found - please check the ID and try again.");
}
get_logged_in_user(true);
get_logged_in_user(false);
page_head("Account data for $user->name");
start_table();

View File

@ -268,12 +268,13 @@ static double estimate_wallclock_duration(
//
static int get_host_info(SCHEDULER_REPLY& reply) {
char buf[8096];
std::string str;
extract_venue(reply.user.project_prefs, reply.host.venue, buf);
str = buf;
std::string str;
unsigned int pos = 0;
int temp_int;
extract_venue(reply.user.project_prefs, reply.host.venue, buf);
str = buf;
// scan user's project prefs for elements of the form <app_id>N</app_id>,
// indicating the apps they want to run.
//