");
if ($publickey) {
- table_row("To protect project's webpages from spam, we ask you to type in two words shown in the image:
\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:
\n".
+ recaptcha_get_html($publickey));
}
table_row("");
}
@@ -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);
diff --git a/html/user/create_profile.php b/html/user/create_profile.php
index 7de0a8232c..f28d6470ef 100644
--- a/html/user/create_profile.php
+++ b/html/user/create_profile.php
@@ -2,8 +2,6 @@
require_once("../inc/profile.inc");
-db_init();
-
$user = get_logged_in_user(true);
show_profile_creation_page($user);
diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php
index 4131314313..58ad7226a4 100644
--- a/html/user/profile_menu.php
+++ b/html/user/profile_menu.php
@@ -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.
";
+ 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();
}
}
diff --git a/html/user/profile_search_action.php b/html/user/profile_search_action.php
index c4c424fef1..51efdce60e 100644
--- a/html/user/profile_search_action.php
+++ b/html/user/profile_search_action.php
@@ -20,7 +20,13 @@ page_head("Profile search results");
echo "
Profiles containing '$search_string'
\n";
$q = "select * from profile where match(response1, response2) against ('$search_string') limit $offset,$count";
$result = mysql_query($q);
-echo "User name | Joined project | Country | Total credit | Recent credit |
";
+echo "
+ User name |
+ Joined project |
+ Country |
+ Total credit |
+ Recent credit |
+";
$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 "
";
mysql_free_result($result);
+
if ($offset==0 && $n==0) {
echo "No profiles found containing '$search_string'";
}
diff --git a/lib/prefs.C b/lib/prefs.C
index 26632ab0c1..9b72299910 100644
--- a/lib/prefs.C
+++ b/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 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(" \n");
- f.printf(" %d\n", i);
- if (cpu) {
- f.printf(" %.02f\n", cpu->start_hour);
- f.printf(" %.02f\n", cpu->end_hour);
- }
- if (net) {
- f.printf(" %.02f\n", net->start_hour);
- f.printf(" %.02f\n", net->end_hour);
- }
- f.printf(" \n");
- }
- }
+ //write only when needed
+ if (net || cpu) {
+
+ f.printf(" \n");
+ f.printf(" %d\n", i);
+ if (cpu) {
+ f.printf(" %.02f\n", cpu->start_hour);
+ f.printf(" %.02f\n", cpu->end_hour);
+ }
+ if (net) {
+ f.printf(" %.02f\n", net->start_hour);
+ f.printf(" %.02f\n", net->end_hour);
+ }
+ f.printf(" \n");
+ }
+ }
f.printf("\n");
return 0;
@@ -786,28 +774,25 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) {
f.printf(" %f\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(" \n");
- f.printf(" %d\n", i);
- if (cpu) {
- f.printf(" %.02f\n", cpu->start_hour);
- f.printf(" %.02f\n", cpu->end_hour);
- }
- if (net) {
- f.printf(" %.02f\n", net->start_hour);
- f.printf(" %.02f\n", net->end_hour);
- }
- f.printf(" \n");
- }
- }
-
+ //write only when needed
+ if (net || cpu) {
+ f.printf(" \n");
+ f.printf(" %d\n", i);
+ if (cpu) {
+ f.printf(" %.02f\n", cpu->start_hour);
+ f.printf(" %.02f\n", cpu->end_hour);
+ }
+ if (net) {
+ f.printf(" %.02f\n", net->start_hour);
+ f.printf(" %.02f\n", net->end_hour);
+ }
+ f.printf(" \n");
+ }
+ }
f.printf("\n");
-
return 0;
}