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
|
||||
pending.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");
|
||||
|
||||
class BoincDb extends DbConn {
|
||||
public static $instance;
|
||||
static $instance;
|
||||
|
||||
static function get() {
|
||||
if (!isset($instance)) {
|
||||
|
@ -99,9 +99,9 @@ class BoincResult {
|
|||
$db = BoincDb::get();
|
||||
return $db->enum('result', 'BoincResult', $clause);
|
||||
}
|
||||
static function update_multi($clause) {
|
||||
static function update_aux($clause) {
|
||||
$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)
|
||||
|
||||
class DbConn {
|
||||
private $db_conn;
|
||||
private $db_name;
|
||||
var $db_conn;
|
||||
var $db_name;
|
||||
|
||||
function init_conn($user_tag, $passwd_tag, $host_tag, $name_tag) {
|
||||
$config = get_config();
|
||||
|
@ -75,7 +75,7 @@ class DbConn {
|
|||
$query = "update DBNAME.$table set $clause where id=$obj->id";
|
||||
return $this->do_query($query);
|
||||
}
|
||||
function update_multi($table, $clause) {
|
||||
function update_aux($table, $clause) {
|
||||
$query = "update DBNAME.$table set $clause";
|
||||
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";
|
||||
|
||||
// decay the average credit of both hosts
|
||||
//
|
||||
$now = 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);
|
||||
// decay the average credit of both hosts
|
||||
//
|
||||
$now = 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 the database:
|
||||
// - add credit from old to new host
|
||||
|
@ -423,7 +423,7 @@ function merge_hosts($old_host, $new_host) {
|
|||
if (!$result) {
|
||||
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) {
|
||||
return "Couldn't update results";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
$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/sanitize_html.inc");
|
||||
require_once("../inc/cache.inc");
|
||||
|
@ -62,13 +62,7 @@ function show_combo_box($name, $filename, $selection=null) {
|
|||
}
|
||||
|
||||
function get_profile($userid) {
|
||||
$result = mysql_query("SELECT * FROM profile WHERE userid = $userid");
|
||||
if (!$result) {
|
||||
return NULL;
|
||||
}
|
||||
$profile = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
return $profile;
|
||||
return BoincProfile::lookup("userid = $userid");
|
||||
}
|
||||
|
||||
function show_profile_creation_page($user) {
|
||||
|
@ -77,17 +71,18 @@ function show_profile_creation_page($user) {
|
|||
//
|
||||
$profile = get_profile($user->id);
|
||||
if (post_str("submit", true)) {
|
||||
$config = get_config();
|
||||
$privatekey = parse_config($config, "<recaptcha_private_key>");
|
||||
if ($privatekey) {
|
||||
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"],
|
||||
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
|
||||
|
||||
if (!$resp->is_valid) {
|
||||
error_page("The reCAPTCHA wasn't entered correctly. Go back and try it again.<br>".
|
||||
"(reCAPTCHA said: " . $resp->error . ")");
|
||||
}
|
||||
}
|
||||
$config = get_config();
|
||||
$privatekey = parse_config($config, "<recaptcha_private_key>");
|
||||
if ($privatekey) {
|
||||
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"],
|
||||
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]
|
||||
);
|
||||
if (!$resp->is_valid) {
|
||||
error_page("The reCAPTCHA wasn't entered correctly. Go back and try it again.<br>".
|
||||
"(reCAPTCHA said: " . $resp->error . ")"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
process_create_profile($user, $profile);
|
||||
exit();
|
||||
|
@ -125,10 +120,10 @@ function show_questions($profile) {
|
|||
$response1 = "";
|
||||
$response2 = "";
|
||||
if (isset($profile->response1)) {
|
||||
$response1 = stripslashes($profile->response1);
|
||||
$response1 = stripslashes($profile->response1);
|
||||
}
|
||||
if (isset($profile->response2)) {
|
||||
$response2 = stripslashes($profile->response2);
|
||||
$response2 = stripslashes($profile->response2);
|
||||
}
|
||||
|
||||
row1(show_profile_heading1());
|
||||
|
@ -233,8 +228,8 @@ function show_submit() {
|
|||
$config = get_config();
|
||||
$publickey = parse_config($config, "<recaptcha_public_key>");
|
||||
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".
|
||||
recaptcha_get_html($publickey));
|
||||
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));
|
||||
}
|
||||
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);
|
||||
$response2 = sanitize_html($response2);
|
||||
if ($profile) {
|
||||
$query = 'UPDATE profile SET '
|
||||
." response1 = '".boinc_real_escape_string($response1)."',"
|
||||
$query = " response1 = '".boinc_real_escape_string($response1)."',"
|
||||
." response2 = '".boinc_real_escape_string($response2)."',"
|
||||
." language = '".boinc_real_escape_string($language)."',"
|
||||
." has_picture = '$hasPicture',"
|
||||
." verification = '$profile->verification'"
|
||||
." WHERE userid = '$user->id'";
|
||||
$result = mysql_query($query);
|
||||
$result = BoincProfile::update_aux($query);
|
||||
if (!$result) {
|
||||
echo mysql_error();
|
||||
profile_error_page("Couldn't update profile: database error");
|
||||
}
|
||||
} else {
|
||||
$query = 'INSERT INTO profile SET '
|
||||
$query = 'SET '
|
||||
." userid = '$user->id',"
|
||||
." language = '".boinc_real_escape_string($language)."',"
|
||||
." response1 = '".boinc_real_escape_string($response1)."',"
|
||||
." response2 = '".boinc_real_escape_string($response2)."',"
|
||||
." has_picture = '$hasPicture',"
|
||||
." verification=0";
|
||||
$result = mysql_query($query);
|
||||
$result = BoincProfile::insert($query);
|
||||
if (!$result) {
|
||||
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);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
require_once("../inc/profile.inc");
|
||||
|
||||
db_init();
|
||||
|
||||
$user = get_logged_in_user(true);
|
||||
show_profile_creation_page($user);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
$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/profile.inc");
|
||||
require_once("../inc/uotd.inc");
|
||||
|
@ -84,25 +84,25 @@ function select_profile($cmd) {
|
|||
// Request for a random profile.
|
||||
//
|
||||
if ($cmd == "rand") {
|
||||
$profiles = array();
|
||||
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) {
|
||||
$result = mysql_query("SELECT userid FROM profile WHERE has_picture=1");
|
||||
$profiles = BoincProfile::enum("has_picture=1");
|
||||
} else if ($_GET['pic'] == -1) {
|
||||
$result = mysql_query("SELECT userid FROM profile");
|
||||
$profiles = BoincProfile::enum(null);
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
$userIds[] = $row[0];
|
||||
}
|
||||
|
||||
if (count($userIds) == 0) {
|
||||
if (count($profiles) == 0) {
|
||||
page_head("No profiles");
|
||||
echo "No profiles matched your query.<br>";
|
||||
page_tail();
|
||||
exit();
|
||||
}
|
||||
|
||||
shuffle($userIds);
|
||||
header("Location: " . URL_BASE . "/view_profile.php?userid=" . $userIds[0]);
|
||||
shuffle($profiles);
|
||||
$userid = $profiles[0]->userid;
|
||||
header("Location: ".URL_BASE."/view_profile.php?userid=$userid");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,13 @@ page_head("Profile search results");
|
|||
echo "<h2>Profiles containing '$search_string'</h2>\n";
|
||||
$q = "select * from profile where match(response1, response2) against ('$search_string') limit $offset,$count";
|
||||
$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;
|
||||
while ($profile = mysql_fetch_object($result)) {
|
||||
show_profile_link($profile, $n+$offset+1);
|
||||
|
@ -28,6 +34,7 @@ while ($profile = mysql_fetch_object($result)) {
|
|||
}
|
||||
echo "</table>";
|
||||
mysql_free_result($result);
|
||||
|
||||
if ($offset==0 && $n==0) {
|
||||
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_min_free_gb = true;
|
||||
vm_max_used_frac = true;
|
||||
ram_max_used_busy_frac = true;
|
||||
ram_max_used_idle_frac = true;
|
||||
ram_max_used_busy_frac = true;
|
||||
ram_max_used_idle_frac = true;
|
||||
idle_time_to_run = true;
|
||||
max_bytes_sec_up = 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_min_free_gb) return true;
|
||||
if (vm_max_used_frac) return true;
|
||||
if (ram_max_used_busy_frac) return true;
|
||||
if (ram_max_used_idle_frac) return true;
|
||||
if (ram_max_used_busy_frac) return true;
|
||||
if (ram_max_used_idle_frac) return true;
|
||||
if (idle_time_to_run) return true;
|
||||
if (max_bytes_sec_up) return true;
|
||||
if (max_bytes_sec_down) return true;
|
||||
|
@ -121,7 +121,6 @@ bool GLOBAL_PREFS_MASK::are_simple_prefs_set() {
|
|||
// TIME_SPAN implementation
|
||||
|
||||
bool TIME_SPAN::suspended(double hour) const {
|
||||
|
||||
if (start_hour == end_hour) return false;
|
||||
if (start_hour == 0 && end_hour == 24) return false;
|
||||
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 {
|
||||
|
||||
if (end_hour == start_hour || (start_hour == 0.0 && end_hour == 24.0)) {
|
||||
return Always;
|
||||
} else if (start_hour == 24.0 && end_hour == 0.0) {
|
||||
|
@ -169,16 +167,14 @@ bool TIME_PREFS::suspended() const {
|
|||
// WEEK_PREFS implementation
|
||||
|
||||
WEEK_PREFS::WEEK_PREFS() {
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int i=0; i<7; i++) {
|
||||
days[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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];
|
||||
if (time) {
|
||||
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) {
|
||||
|
||||
if (this != &rhs) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int i=0; i<7; i++) {
|
||||
TIME_SPAN* time = rhs.days[i];
|
||||
if (time) {
|
||||
if (days[i]) {
|
||||
|
@ -211,8 +206,7 @@ WEEK_PREFS& WEEK_PREFS::operator=(const WEEK_PREFS& rhs) {
|
|||
|
||||
// Create a deep copy.
|
||||
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];
|
||||
if (time) {
|
||||
days[i] = new TIME_SPAN(time->start_hour, time->end_hour);
|
||||
|
@ -229,8 +223,7 @@ WEEK_PREFS::~WEEK_PREFS() {
|
|||
|
||||
|
||||
void WEEK_PREFS::clear() {
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int i=0; i<7; i++) {
|
||||
if (days[i]) {
|
||||
delete days[i];
|
||||
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) {
|
||||
|
||||
if (day < 0 || day > 6) return;
|
||||
|
||||
if (days[day]) delete days[day];
|
||||
days[day] = new TIME_SPAN(start, end);
|
||||
}
|
||||
|
||||
|
||||
void WEEK_PREFS::set(int day, TIME_SPAN* time) {
|
||||
|
||||
if (day < 0 || day > 6) return;
|
||||
if (days[day] == time) return;
|
||||
if (days[day]) delete days[day];
|
||||
|
||||
days[day] = time;
|
||||
}
|
||||
|
||||
void WEEK_PREFS::unset(int day) {
|
||||
|
||||
if (day < 0 || day > 6) return;
|
||||
|
||||
if (days[day]) {
|
||||
delete days[day];
|
||||
days[day] = 0;
|
||||
|
@ -299,11 +286,12 @@ void GLOBAL_PREFS::defaults() {
|
|||
disk_max_used_pct = 50;
|
||||
disk_min_free_gb = 0.1;
|
||||
vm_max_used_frac = 0.75;
|
||||
ram_max_used_busy_frac = 0.5;
|
||||
ram_max_used_idle_frac = 0.9;
|
||||
ram_max_used_busy_frac = 0.5;
|
||||
ram_max_used_idle_frac = 0.9;
|
||||
max_bytes_sec_up = 0;
|
||||
max_bytes_sec_down = 0;
|
||||
cpu_usage_limit = 100;
|
||||
|
||||
// don't initialize source_project, source_scheduler,
|
||||
// mod_time, host_specific here
|
||||
// since they are outside of <venue> elements,
|
||||
|
@ -537,19 +525,19 @@ int GLOBAL_PREFS::parse_override(
|
|||
continue;
|
||||
}
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
if (xp.parse_double(tag, "ram_max_used_busy_pct", dtemp)) {
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
if (xp.parse_double(tag, "ram_max_used_idle_pct", dtemp)) {
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
@ -653,33 +641,33 @@ int GLOBAL_PREFS::write(MIOFILE& f) {
|
|||
disk_max_used_pct,
|
||||
disk_min_free_gb,
|
||||
vm_max_used_frac*100,
|
||||
ram_max_used_busy_frac*100,
|
||||
ram_max_used_idle_frac*100,
|
||||
ram_max_used_busy_frac*100,
|
||||
ram_max_used_idle_frac*100,
|
||||
idle_time_to_run,
|
||||
max_bytes_sec_up,
|
||||
max_bytes_sec_down,
|
||||
cpu_usage_limit
|
||||
);
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||
for (int i=0; i<7; i++) {
|
||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||
TIME_SPAN* net = net_times.week.get(i);
|
||||
//write only when needed
|
||||
if (net || cpu) {
|
||||
|
||||
f.printf(" <day_prefs>\n");
|
||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||
if (cpu) {
|
||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||
}
|
||||
if (net) {
|
||||
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(" </day_prefs>\n");
|
||||
}
|
||||
}
|
||||
//write only when needed
|
||||
if (net || cpu) {
|
||||
|
||||
f.printf(" <day_prefs>\n");
|
||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||
if (cpu) {
|
||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||
}
|
||||
if (net) {
|
||||
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(" </day_prefs>\n");
|
||||
}
|
||||
}
|
||||
f.printf("</global_preferences>\n");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||
for (int i=0; i<7; i++) {
|
||||
TIME_SPAN* cpu = cpu_times.week.get(i);
|
||||
TIME_SPAN* net = net_times.week.get(i);
|
||||
//write only when needed
|
||||
if (net || cpu) {
|
||||
|
||||
f.printf(" <day_prefs>\n");
|
||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||
if (cpu) {
|
||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||
}
|
||||
if (net) {
|
||||
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(" </day_prefs>\n");
|
||||
}
|
||||
}
|
||||
|
||||
//write only when needed
|
||||
if (net || cpu) {
|
||||
f.printf(" <day_prefs>\n");
|
||||
f.printf(" <day_of_week>%d</day_of_week>\n", i);
|
||||
if (cpu) {
|
||||
f.printf(" <start_hour>%.02f</start_hour>\n", cpu->start_hour);
|
||||
f.printf(" <end_hour>%.02f</end_hour>\n", cpu->end_hour);
|
||||
}
|
||||
if (net) {
|
||||
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(" </day_prefs>\n");
|
||||
}
|
||||
}
|
||||
f.printf("</global_preferences>\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue