mirror of https://github.com/BOINC/boinc.git
- user web: more of the above.
Also, try to make it PHP 4 compatible svn path=/trunk/boinc/; revision=13982
This commit is contained in:
parent
dc4ca1e5cd
commit
ee1621c566
|
@ -10113,3 +10113,20 @@ David 28 Oct 2007
|
||||||
merge_by_name.php
|
merge_by_name.php
|
||||||
pending.php
|
pending.php
|
||||||
top_hosts.php
|
top_hosts.php
|
||||||
|
|
||||||
|
David 28 Oct 2007
|
||||||
|
- user web: more of the above.
|
||||||
|
Also, try to make it PHP 4 compatible
|
||||||
|
|
||||||
|
html/
|
||||||
|
inc/
|
||||||
|
boinc_db.inc
|
||||||
|
db_conn.inc
|
||||||
|
host.inc
|
||||||
|
profile.inc
|
||||||
|
user/
|
||||||
|
create_profile.php
|
||||||
|
profile_menu.php
|
||||||
|
profile_search_action.php
|
||||||
|
lib/
|
||||||
|
prefs.C
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require_once("../inc/db_conn.inc");
|
require_once("../inc/db_conn.inc");
|
||||||
|
|
||||||
class BoincDb extends DbConn {
|
class BoincDb extends DbConn {
|
||||||
public static $instance;
|
static $instance;
|
||||||
|
|
||||||
static function get() {
|
static function get() {
|
||||||
if (!isset($instance)) {
|
if (!isset($instance)) {
|
||||||
|
@ -99,9 +99,9 @@ class BoincResult {
|
||||||
$db = BoincDb::get();
|
$db = BoincDb::get();
|
||||||
return $db->enum('result', 'BoincResult', $clause);
|
return $db->enum('result', 'BoincResult', $clause);
|
||||||
}
|
}
|
||||||
static function update_multi($clause) {
|
static function update_aux($clause) {
|
||||||
$db = BoincDb::get();
|
$db = BoincDb::get();
|
||||||
return $db->update_multi('result', $clause);
|
return $db->update_aux('result', $clause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,4 +112,23 @@ class BoincPost {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BoincProfile {
|
||||||
|
static function lookup($clause) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->lookup('profile', 'BoincProfile', $clause);
|
||||||
|
}
|
||||||
|
static function update_aux($clause) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->update_aux('profile', $clause);
|
||||||
|
}
|
||||||
|
static function insert($clause) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->insert('profile', $clause);
|
||||||
|
}
|
||||||
|
static function enum($clause) {
|
||||||
|
$db = BoincDb::get();
|
||||||
|
return $db->enum('profile', 'BoincProfile', $clause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -7,8 +7,8 @@ error_reporting(E_ALL);
|
||||||
// Intended to be subclassed (e.g., BoincDb, BossaDb)
|
// Intended to be subclassed (e.g., BoincDb, BossaDb)
|
||||||
|
|
||||||
class DbConn {
|
class DbConn {
|
||||||
private $db_conn;
|
var $db_conn;
|
||||||
private $db_name;
|
var $db_name;
|
||||||
|
|
||||||
function init_conn($user_tag, $passwd_tag, $host_tag, $name_tag) {
|
function init_conn($user_tag, $passwd_tag, $host_tag, $name_tag) {
|
||||||
$config = get_config();
|
$config = get_config();
|
||||||
|
@ -75,7 +75,7 @@ class DbConn {
|
||||||
$query = "update DBNAME.$table set $clause where id=$obj->id";
|
$query = "update DBNAME.$table set $clause where id=$obj->id";
|
||||||
return $this->do_query($query);
|
return $this->do_query($query);
|
||||||
}
|
}
|
||||||
function update_multi($table, $clause) {
|
function update_aux($table, $clause) {
|
||||||
$query = "update DBNAME.$table set $clause";
|
$query = "update DBNAME.$table set $clause";
|
||||||
return $this->do_query($query);
|
return $this->do_query($query);
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,11 +405,11 @@ function merge_hosts($old_host, $new_host) {
|
||||||
|
|
||||||
echo "<br>Merging host $old_host->id into host $new_host->id\n";
|
echo "<br>Merging host $old_host->id into host $new_host->id\n";
|
||||||
|
|
||||||
// decay the average credit of both hosts
|
// decay the average credit of both hosts
|
||||||
//
|
//
|
||||||
$now = time();
|
$now = time();
|
||||||
update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
|
update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
|
||||||
update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
|
update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
|
||||||
|
|
||||||
// update the database:
|
// update the database:
|
||||||
// - add credit from old to new host
|
// - add credit from old to new host
|
||||||
|
@ -423,7 +423,7 @@ function merge_hosts($old_host, $new_host) {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return "Couldn't update credit of new computer";
|
return "Couldn't update credit of new computer";
|
||||||
}
|
}
|
||||||
$result = BoincResult::update_multi("hostid=$new_host->id where hostid=$old_host->id");
|
$result = BoincResult::update_aux("hostid=$new_host->id where hostid=$old_host->id");
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return "Couldn't update results";
|
return "Couldn't update results";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
||||||
|
|
||||||
require_once("../inc/db.inc");
|
require_once("../inc/boinc_db.inc");
|
||||||
require_once("../inc/util.inc");
|
require_once("../inc/util.inc");
|
||||||
require_once("../inc/sanitize_html.inc");
|
require_once("../inc/sanitize_html.inc");
|
||||||
require_once("../inc/cache.inc");
|
require_once("../inc/cache.inc");
|
||||||
|
@ -62,13 +62,7 @@ function show_combo_box($name, $filename, $selection=null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_profile($userid) {
|
function get_profile($userid) {
|
||||||
$result = mysql_query("SELECT * FROM profile WHERE userid = $userid");
|
return BoincProfile::lookup("userid = $userid");
|
||||||
if (!$result) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
$profile = mysql_fetch_object($result);
|
|
||||||
mysql_free_result($result);
|
|
||||||
return $profile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_profile_creation_page($user) {
|
function show_profile_creation_page($user) {
|
||||||
|
@ -77,17 +71,18 @@ function show_profile_creation_page($user) {
|
||||||
//
|
//
|
||||||
$profile = get_profile($user->id);
|
$profile = get_profile($user->id);
|
||||||
if (post_str("submit", true)) {
|
if (post_str("submit", true)) {
|
||||||
$config = get_config();
|
$config = get_config();
|
||||||
$privatekey = parse_config($config, "<recaptcha_private_key>");
|
$privatekey = parse_config($config, "<recaptcha_private_key>");
|
||||||
if ($privatekey) {
|
if ($privatekey) {
|
||||||
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"],
|
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"],
|
||||||
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
|
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]
|
||||||
|
);
|
||||||
if (!$resp->is_valid) {
|
if (!$resp->is_valid) {
|
||||||
error_page("The reCAPTCHA wasn't entered correctly. Go back and try it again.<br>".
|
error_page("The reCAPTCHA wasn't entered correctly. Go back and try it again.<br>".
|
||||||
"(reCAPTCHA said: " . $resp->error . ")");
|
"(reCAPTCHA said: " . $resp->error . ")"
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
process_create_profile($user, $profile);
|
process_create_profile($user, $profile);
|
||||||
exit();
|
exit();
|
||||||
|
@ -125,10 +120,10 @@ function show_questions($profile) {
|
||||||
$response1 = "";
|
$response1 = "";
|
||||||
$response2 = "";
|
$response2 = "";
|
||||||
if (isset($profile->response1)) {
|
if (isset($profile->response1)) {
|
||||||
$response1 = stripslashes($profile->response1);
|
$response1 = stripslashes($profile->response1);
|
||||||
}
|
}
|
||||||
if (isset($profile->response2)) {
|
if (isset($profile->response2)) {
|
||||||
$response2 = stripslashes($profile->response2);
|
$response2 = stripslashes($profile->response2);
|
||||||
}
|
}
|
||||||
|
|
||||||
row1(show_profile_heading1());
|
row1(show_profile_heading1());
|
||||||
|
@ -233,8 +228,8 @@ function show_submit() {
|
||||||
$config = get_config();
|
$config = get_config();
|
||||||
$publickey = parse_config($config, "<recaptcha_public_key>");
|
$publickey = parse_config($config, "<recaptcha_public_key>");
|
||||||
if ($publickey) {
|
if ($publickey) {
|
||||||
table_row("To protect project's webpages from spam, we ask you to type in two words shown in the image:<br>\n".
|
table_row("To protect project's webpages from spam, we ask you to type in two words shown in the image:<br>\n".
|
||||||
recaptcha_get_html($publickey));
|
recaptcha_get_html($publickey));
|
||||||
}
|
}
|
||||||
table_row("<p><input type=\"submit\" value=\"Create/edit profile\" name=\"submit\">");
|
table_row("<p><input type=\"submit\" value=\"Create/edit profile\" name=\"submit\">");
|
||||||
}
|
}
|
||||||
|
@ -303,31 +298,29 @@ function process_create_profile($user, $profile) {
|
||||||
$response1 = sanitize_html($response1);
|
$response1 = sanitize_html($response1);
|
||||||
$response2 = sanitize_html($response2);
|
$response2 = sanitize_html($response2);
|
||||||
if ($profile) {
|
if ($profile) {
|
||||||
$query = 'UPDATE profile SET '
|
$query = " response1 = '".boinc_real_escape_string($response1)."',"
|
||||||
." response1 = '".boinc_real_escape_string($response1)."',"
|
|
||||||
." response2 = '".boinc_real_escape_string($response2)."',"
|
." response2 = '".boinc_real_escape_string($response2)."',"
|
||||||
." language = '".boinc_real_escape_string($language)."',"
|
." language = '".boinc_real_escape_string($language)."',"
|
||||||
." has_picture = '$hasPicture',"
|
." has_picture = '$hasPicture',"
|
||||||
." verification = '$profile->verification'"
|
." verification = '$profile->verification'"
|
||||||
." WHERE userid = '$user->id'";
|
." WHERE userid = '$user->id'";
|
||||||
$result = mysql_query($query);
|
$result = BoincProfile::update_aux($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
echo mysql_error();
|
|
||||||
profile_error_page("Couldn't update profile: database error");
|
profile_error_page("Couldn't update profile: database error");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query = 'INSERT INTO profile SET '
|
$query = 'SET '
|
||||||
." userid = '$user->id',"
|
." userid = '$user->id',"
|
||||||
." language = '".boinc_real_escape_string($language)."',"
|
." language = '".boinc_real_escape_string($language)."',"
|
||||||
." response1 = '".boinc_real_escape_string($response1)."',"
|
." response1 = '".boinc_real_escape_string($response1)."',"
|
||||||
." response2 = '".boinc_real_escape_string($response2)."',"
|
." response2 = '".boinc_real_escape_string($response2)."',"
|
||||||
." has_picture = '$hasPicture',"
|
." has_picture = '$hasPicture',"
|
||||||
." verification=0";
|
." verification=0";
|
||||||
$result = mysql_query($query);
|
$result = BoincProfile::insert($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
profile_error_page("Couldn't create profile: database error");
|
profile_error_page("Couldn't create profile: database error");
|
||||||
}
|
}
|
||||||
mysql_query("update user set has_profile=1 where id=$user->id");
|
$user->update("has_profile=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
show_result_page($user);
|
show_result_page($user);
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require_once("../inc/profile.inc");
|
require_once("../inc/profile.inc");
|
||||||
|
|
||||||
db_init();
|
|
||||||
|
|
||||||
$user = get_logged_in_user(true);
|
$user = get_logged_in_user(true);
|
||||||
show_profile_creation_page($user);
|
show_profile_creation_page($user);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
||||||
|
|
||||||
require_once("../inc/db.inc");
|
require_once("../inc/boinc_db.inc");
|
||||||
require_once("../inc/util.inc");
|
require_once("../inc/util.inc");
|
||||||
require_once("../inc/profile.inc");
|
require_once("../inc/profile.inc");
|
||||||
require_once("../inc/uotd.inc");
|
require_once("../inc/uotd.inc");
|
||||||
|
@ -84,25 +84,25 @@ function select_profile($cmd) {
|
||||||
// Request for a random profile.
|
// Request for a random profile.
|
||||||
//
|
//
|
||||||
if ($cmd == "rand") {
|
if ($cmd == "rand") {
|
||||||
|
$profiles = array();
|
||||||
if ($_GET['pic'] == 0) {
|
if ($_GET['pic'] == 0) {
|
||||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture=0");
|
$profiles = BoincProfile::enum("has_picture=0");
|
||||||
} else if ($_GET['pic'] == 1) {
|
} else if ($_GET['pic'] == 1) {
|
||||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture=1");
|
$profiles = BoincProfile::enum("has_picture=1");
|
||||||
} else if ($_GET['pic'] == -1) {
|
} else if ($_GET['pic'] == -1) {
|
||||||
$result = mysql_query("SELECT userid FROM profile");
|
$profiles = BoincProfile::enum(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($row = mysql_fetch_row($result)) {
|
if (count($profiles) == 0) {
|
||||||
$userIds[] = $row[0];
|
page_head("No profiles");
|
||||||
}
|
|
||||||
|
|
||||||
if (count($userIds) == 0) {
|
|
||||||
echo "No profiles matched your query.<br>";
|
echo "No profiles matched your query.<br>";
|
||||||
|
page_tail();
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
shuffle($userIds);
|
shuffle($profiles);
|
||||||
header("Location: " . URL_BASE . "/view_profile.php?userid=" . $userIds[0]);
|
$userid = $profiles[0]->userid;
|
||||||
|
header("Location: ".URL_BASE."/view_profile.php?userid=$userid");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,13 @@ page_head("Profile search results");
|
||||||
echo "<h2>Profiles containing '$search_string'</h2>\n";
|
echo "<h2>Profiles containing '$search_string'</h2>\n";
|
||||||
$q = "select * from profile where match(response1, response2) against ('$search_string') limit $offset,$count";
|
$q = "select * from profile where match(response1, response2) against ('$search_string') limit $offset,$count";
|
||||||
$result = mysql_query($q);
|
$result = mysql_query($q);
|
||||||
echo "<table align=\"center\" cellpadding=\"1\" border=\"1\" width=\"90%\"><tr><th align=\"center\">User name</th><th align=\"center\">Joined project</th><th align=\"center\">Country</th><th align=\"center\">Total credit</th><th align=\"center\">Recent credit</th></tr>";
|
echo "<table align=\"center\" cellpadding=\"1\" border=\"1\" width=\"90%\">
|
||||||
|
<tr><th align=\"center\">User name</th>
|
||||||
|
<th align=\"center\">Joined project</th>
|
||||||
|
<th align=\"center\">Country</th>
|
||||||
|
<th align=\"center\">Total credit</th>
|
||||||
|
<th align=\"center\">Recent credit</th></tr>
|
||||||
|
";
|
||||||
$n = 0;
|
$n = 0;
|
||||||
while ($profile = mysql_fetch_object($result)) {
|
while ($profile = mysql_fetch_object($result)) {
|
||||||
show_profile_link($profile, $n+$offset+1);
|
show_profile_link($profile, $n+$offset+1);
|
||||||
|
@ -28,6 +34,7 @@ while ($profile = mysql_fetch_object($result)) {
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
mysql_free_result($result);
|
mysql_free_result($result);
|
||||||
|
|
||||||
if ($offset==0 && $n==0) {
|
if ($offset==0 && $n==0) {
|
||||||
echo "No profiles found containing '$search_string'";
|
echo "No profiles found containing '$search_string'";
|
||||||
}
|
}
|
||||||
|
|
119
lib/prefs.C
119
lib/prefs.C
|
@ -65,8 +65,8 @@ void GLOBAL_PREFS_MASK::set_all() {
|
||||||
disk_max_used_pct = true;
|
disk_max_used_pct = true;
|
||||||
disk_min_free_gb = true;
|
disk_min_free_gb = true;
|
||||||
vm_max_used_frac = true;
|
vm_max_used_frac = true;
|
||||||
ram_max_used_busy_frac = true;
|
ram_max_used_busy_frac = true;
|
||||||
ram_max_used_idle_frac = true;
|
ram_max_used_idle_frac = true;
|
||||||
idle_time_to_run = true;
|
idle_time_to_run = true;
|
||||||
max_bytes_sec_up = true;
|
max_bytes_sec_up = true;
|
||||||
max_bytes_sec_down = true;
|
max_bytes_sec_down = true;
|
||||||
|
@ -95,8 +95,8 @@ bool GLOBAL_PREFS_MASK::are_prefs_set() {
|
||||||
if (disk_max_used_pct) return true;
|
if (disk_max_used_pct) return true;
|
||||||
if (disk_min_free_gb) return true;
|
if (disk_min_free_gb) return true;
|
||||||
if (vm_max_used_frac) return true;
|
if (vm_max_used_frac) return true;
|
||||||
if (ram_max_used_busy_frac) return true;
|
if (ram_max_used_busy_frac) return true;
|
||||||
if (ram_max_used_idle_frac) return true;
|
if (ram_max_used_idle_frac) return true;
|
||||||
if (idle_time_to_run) return true;
|
if (idle_time_to_run) return true;
|
||||||
if (max_bytes_sec_up) return true;
|
if (max_bytes_sec_up) return true;
|
||||||
if (max_bytes_sec_down) return true;
|
if (max_bytes_sec_down) return true;
|
||||||
|
@ -121,7 +121,6 @@ bool GLOBAL_PREFS_MASK::are_simple_prefs_set() {
|
||||||
// TIME_SPAN implementation
|
// TIME_SPAN implementation
|
||||||
|
|
||||||
bool TIME_SPAN::suspended(double hour) const {
|
bool TIME_SPAN::suspended(double hour) const {
|
||||||
|
|
||||||
if (start_hour == end_hour) return false;
|
if (start_hour == end_hour) return false;
|
||||||
if (start_hour == 0 && end_hour == 24) return false;
|
if (start_hour == 0 && end_hour == 24) return false;
|
||||||
if (start_hour == 24 && end_hour == 0) return true;
|
if (start_hour == 24 && end_hour == 0) return true;
|
||||||
|
@ -134,7 +133,6 @@ bool TIME_SPAN::suspended(double hour) const {
|
||||||
|
|
||||||
|
|
||||||
TIME_SPAN::TimeMode TIME_SPAN::mode() const {
|
TIME_SPAN::TimeMode TIME_SPAN::mode() const {
|
||||||
|
|
||||||
if (end_hour == start_hour || (start_hour == 0.0 && end_hour == 24.0)) {
|
if (end_hour == start_hour || (start_hour == 0.0 && end_hour == 24.0)) {
|
||||||
return Always;
|
return Always;
|
||||||
} else if (start_hour == 24.0 && end_hour == 0.0) {
|
} else if (start_hour == 24.0 && end_hour == 0.0) {
|
||||||
|
@ -169,16 +167,14 @@ bool TIME_PREFS::suspended() const {
|
||||||
// WEEK_PREFS implementation
|
// WEEK_PREFS implementation
|
||||||
|
|
||||||
WEEK_PREFS::WEEK_PREFS() {
|
WEEK_PREFS::WEEK_PREFS() {
|
||||||
|
for (int i=0; i<7; i++) {
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
days[i] = 0;
|
days[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WEEK_PREFS::WEEK_PREFS(const WEEK_PREFS& original) {
|
WEEK_PREFS::WEEK_PREFS(const WEEK_PREFS& original) {
|
||||||
|
for (int i=0; i<7; i++) {
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
TIME_SPAN* time = original.days[i];
|
TIME_SPAN* time = original.days[i];
|
||||||
if (time) {
|
if (time) {
|
||||||
days[i] = new TIME_SPAN(time->start_hour, time->end_hour);
|
days[i] = new TIME_SPAN(time->start_hour, time->end_hour);
|
||||||
|
@ -190,9 +186,8 @@ WEEK_PREFS::WEEK_PREFS(const WEEK_PREFS& original) {
|
||||||
|
|
||||||
|
|
||||||
WEEK_PREFS& WEEK_PREFS::operator=(const WEEK_PREFS& rhs) {
|
WEEK_PREFS& WEEK_PREFS::operator=(const WEEK_PREFS& rhs) {
|
||||||
|
|
||||||
if (this != &rhs) {
|
if (this != &rhs) {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i=0; i<7; i++) {
|
||||||
TIME_SPAN* time = rhs.days[i];
|
TIME_SPAN* time = rhs.days[i];
|
||||||
if (time) {
|
if (time) {
|
||||||
if (days[i]) {
|
if (days[i]) {
|
||||||
|
@ -211,8 +206,7 @@ WEEK_PREFS& WEEK_PREFS::operator=(const WEEK_PREFS& rhs) {
|
||||||
|
|
||||||
// Create a deep copy.
|
// Create a deep copy.
|
||||||
void WEEK_PREFS::copy(const WEEK_PREFS& original) {
|
void WEEK_PREFS::copy(const WEEK_PREFS& original) {
|
||||||
|
for (int i=0; i<7; i++) {
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
TIME_SPAN* time = original.days[i];
|
TIME_SPAN* time = original.days[i];
|
||||||
if (time) {
|
if (time) {
|
||||||
days[i] = new TIME_SPAN(time->start_hour, time->end_hour);
|
days[i] = new TIME_SPAN(time->start_hour, time->end_hour);
|
||||||
|
@ -229,8 +223,7 @@ WEEK_PREFS::~WEEK_PREFS() {
|
||||||
|
|
||||||
|
|
||||||
void WEEK_PREFS::clear() {
|
void WEEK_PREFS::clear() {
|
||||||
|
for (int i=0; i<7; i++) {
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
if (days[i]) {
|
if (days[i]) {
|
||||||
delete days[i];
|
delete days[i];
|
||||||
days[i] = 0;
|
days[i] = 0;
|
||||||
|
@ -247,27 +240,21 @@ TIME_SPAN* WEEK_PREFS::get(int day) const {
|
||||||
|
|
||||||
|
|
||||||
void WEEK_PREFS::set(int day, double start, double end) {
|
void WEEK_PREFS::set(int day, double start, double end) {
|
||||||
|
|
||||||
if (day < 0 || day > 6) return;
|
if (day < 0 || day > 6) return;
|
||||||
|
|
||||||
if (days[day]) delete days[day];
|
if (days[day]) delete days[day];
|
||||||
days[day] = new TIME_SPAN(start, end);
|
days[day] = new TIME_SPAN(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WEEK_PREFS::set(int day, TIME_SPAN* time) {
|
void WEEK_PREFS::set(int day, TIME_SPAN* time) {
|
||||||
|
|
||||||
if (day < 0 || day > 6) return;
|
if (day < 0 || day > 6) return;
|
||||||
if (days[day] == time) return;
|
if (days[day] == time) return;
|
||||||
if (days[day]) delete days[day];
|
if (days[day]) delete days[day];
|
||||||
|
|
||||||
days[day] = time;
|
days[day] = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WEEK_PREFS::unset(int day) {
|
void WEEK_PREFS::unset(int day) {
|
||||||
|
|
||||||
if (day < 0 || day > 6) return;
|
if (day < 0 || day > 6) return;
|
||||||
|
|
||||||
if (days[day]) {
|
if (days[day]) {
|
||||||
delete days[day];
|
delete days[day];
|
||||||
days[day] = 0;
|
days[day] = 0;
|
||||||
|
@ -299,11 +286,12 @@ void GLOBAL_PREFS::defaults() {
|
||||||
disk_max_used_pct = 50;
|
disk_max_used_pct = 50;
|
||||||
disk_min_free_gb = 0.1;
|
disk_min_free_gb = 0.1;
|
||||||
vm_max_used_frac = 0.75;
|
vm_max_used_frac = 0.75;
|
||||||
ram_max_used_busy_frac = 0.5;
|
ram_max_used_busy_frac = 0.5;
|
||||||
ram_max_used_idle_frac = 0.9;
|
ram_max_used_idle_frac = 0.9;
|
||||||
max_bytes_sec_up = 0;
|
max_bytes_sec_up = 0;
|
||||||
max_bytes_sec_down = 0;
|
max_bytes_sec_down = 0;
|
||||||
cpu_usage_limit = 100;
|
cpu_usage_limit = 100;
|
||||||
|
|
||||||
// don't initialize source_project, source_scheduler,
|
// don't initialize source_project, source_scheduler,
|
||||||
// mod_time, host_specific here
|
// mod_time, host_specific here
|
||||||
// since they are outside of <venue> elements,
|
// since they are outside of <venue> elements,
|
||||||
|
@ -537,19 +525,19 @@ int GLOBAL_PREFS::parse_override(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (xp.parse_double(tag, "vm_max_used_pct", dtemp)) {
|
if (xp.parse_double(tag, "vm_max_used_pct", dtemp)) {
|
||||||
vm_max_used_frac = dtemp/100;
|
vm_max_used_frac = dtemp/100;
|
||||||
mask.vm_max_used_frac = true;
|
mask.vm_max_used_frac = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (xp.parse_double(tag, "ram_max_used_busy_pct", dtemp)) {
|
if (xp.parse_double(tag, "ram_max_used_busy_pct", dtemp)) {
|
||||||
if (!dtemp) dtemp = 100;
|
if (!dtemp) dtemp = 100;
|
||||||
ram_max_used_busy_frac = dtemp/100;
|
ram_max_used_busy_frac = dtemp/100;
|
||||||
mask.ram_max_used_busy_frac = true;
|
mask.ram_max_used_busy_frac = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (xp.parse_double(tag, "ram_max_used_idle_pct", dtemp)) {
|
if (xp.parse_double(tag, "ram_max_used_idle_pct", dtemp)) {
|
||||||
if (!dtemp) dtemp = 100;
|
if (!dtemp) dtemp = 100;
|
||||||
ram_max_used_idle_frac = dtemp/100;
|
ram_max_used_idle_frac = dtemp/100;
|
||||||
mask.ram_max_used_idle_frac = true;
|
mask.ram_max_used_idle_frac = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -653,33 +641,33 @@ int GLOBAL_PREFS::write(MIOFILE& f) {
|
||||||
disk_max_used_pct,
|
disk_max_used_pct,
|
||||||
disk_min_free_gb,
|
disk_min_free_gb,
|
||||||
vm_max_used_frac*100,
|
vm_max_used_frac*100,
|
||||||
ram_max_used_busy_frac*100,
|
ram_max_used_busy_frac*100,
|
||||||
ram_max_used_idle_frac*100,
|
ram_max_used_idle_frac*100,
|
||||||
idle_time_to_run,
|
idle_time_to_run,
|
||||||
max_bytes_sec_up,
|
max_bytes_sec_up,
|
||||||
max_bytes_sec_down,
|
max_bytes_sec_down,
|
||||||
cpu_usage_limit
|
cpu_usage_limit
|
||||||
);
|
);
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i=0; i<7; i++) {
|
||||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||||
TIME_SPAN* net = net_times.week.get(i);
|
TIME_SPAN* net = net_times.week.get(i);
|
||||||
//write only when needed
|
//write only when needed
|
||||||
if (net || cpu) {
|
if (net || cpu) {
|
||||||
|
|
||||||
f.printf(" <day_prefs>\n");
|
f.printf(" <day_prefs>\n");
|
||||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||||
if (cpu) {
|
if (cpu) {
|
||||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||||
}
|
}
|
||||||
if (net) {
|
if (net) {
|
||||||
f.printf(" <net_start_hour>%.02f</net_start_hour>\n", net->start_hour);
|
f.printf(" <net_start_hour>%.02f</net_start_hour>\n", net->start_hour);
|
||||||
f.printf(" <net_end_hour>%.02f</net_end_hour>\n", net->end_hour);
|
f.printf(" <net_end_hour>%.02f</net_end_hour>\n", net->end_hour);
|
||||||
}
|
}
|
||||||
f.printf(" </day_prefs>\n");
|
f.printf(" </day_prefs>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.printf("</global_preferences>\n");
|
f.printf("</global_preferences>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -786,28 +774,25 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) {
|
||||||
f.printf(" <cpu_usage_limit>%f</cpu_usage_limit>\n", cpu_usage_limit);
|
f.printf(" <cpu_usage_limit>%f</cpu_usage_limit>\n", cpu_usage_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i=0; i<7; i++) {
|
||||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||||
TIME_SPAN* net = net_times.week.get(i);
|
TIME_SPAN* net = net_times.week.get(i);
|
||||||
//write only when needed
|
//write only when needed
|
||||||
if (net || cpu) {
|
if (net || cpu) {
|
||||||
|
f.printf(" <day_prefs>\n");
|
||||||
f.printf(" <day_prefs>\n");
|
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
if (cpu) {
|
||||||
if (cpu) {
|
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
}
|
||||||
}
|
if (net) {
|
||||||
if (net) {
|
f.printf(" <net_start_hour>%.02f</net_start_hour>\n", net->start_hour);
|
||||||
f.printf(" <net_start_hour>%.02f</net_start_hour>\n", net->start_hour);
|
f.printf(" <net_end_hour>%.02f</net_end_hour>\n", net->end_hour);
|
||||||
f.printf(" <net_end_hour>%.02f</net_end_hour>\n", net->end_hour);
|
}
|
||||||
}
|
f.printf(" </day_prefs>\n");
|
||||||
f.printf(" </day_prefs>\n");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
f.printf("</global_preferences>\n");
|
f.printf("</global_preferences>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue