diff --git a/checkin_notes b/checkin_notes
index e74e079b6d..b231ccad04 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -10774,3 +10774,33 @@ David 12 Nov 2007
user/
forum*.php
pm.php (new)
+
+David 12 Nov 2007
+ - user web: update other code to use new-style DB interfaces
+
+ html/
+ inc/
+ akismet.inc
+ boinc_db.inc
+ db.inc
+ db_conn.inc
+ user/
+ account_finish_action.php
+ am_set_info.php
+ apps.php
+ create_account_info.php
+ delete_profile.php
+ edit_email_action.php
+ edit_passwd_action.php
+ forum_edit.php
+ forum_get_data.php
+ home.php
+ login_action.php
+ lookup_account.php
+ opt_out.php
+ pm.php
+ profile_rate.php
+ profile_search_action.php
+ results.php
+ validate_amil_addr.php
+ workunit.php
diff --git a/html/inc/akismet.inc b/html/inc/akismet.inc
index f720fdcea2..d92a790067 100644
--- a/html/inc/akismet.inc
+++ b/html/inc/akismet.inc
@@ -13,7 +13,7 @@ function akismet_check($user, $post) {
$post = urlencode($post);
$ip = urlencode($_SERVER['REMOTE_ADDR']);
$referrer = urlencode($_SERVER['HTTP_REFERER']);
- $author = urlencode($user->getName());
+ $author = urlencode($user->name);
$useragent = urlencode($_SERVER['HTTP_USER_AGENT']);
$request = "blog=$master_url";
@@ -55,4 +55,4 @@ function akismet_request($request, $host, $path, $port = 80) {
return $response;
}
-?>
\ No newline at end of file
+?>
diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc
index 31f367b156..6fe95bfc97 100644
--- a/html/inc/boinc_db.inc
+++ b/html/inc/boinc_db.inc
@@ -45,6 +45,10 @@ class BoincDb extends DbConn {
$db = self::get();
return $db->base_escape_string($string);
}
+ static function error() {
+ $db = self::get();
+ return $db->base_error();
+ }
}
class BoincUser {
@@ -167,6 +171,31 @@ class BoincResult {
}
}
+class BoincWorkunit {
+ static function lookup_id($id) {
+ $db = BoincDb::get();
+ return $db->lookup_id($id, 'workunit', 'BoincWorkunit');
+ }
+}
+
+class BoincApp {
+ static function lookup_id($id) {
+ $db = BoincDb::get();
+ return $db->lookup_id($id, 'app', 'BoincApp');
+ }
+ static function enum($clause) {
+ $db = BoincDb::get();
+ return $db->enum('app', 'BoincApp', $clause);
+ }
+}
+
+class BoincAppVersion {
+ static function enum($clause) {
+ $db = BoincDb::get();
+ return $db->enum('app_version', 'BoincAppVersion', $clause);
+ }
+}
+
class BoincProfile {
static function lookup($clause) {
$db = BoincDb::get();
@@ -184,6 +213,10 @@ class BoincProfile {
$db = BoincDb::get();
return $db->enum('profile', 'BoincProfile', $clause, $clause2);
}
+ function delete_aux() {
+ $db = BoincDb::get();
+ return $db->delete_aux('profile', $clause);
+ }
}
class BoincTeamAdmin {
@@ -230,6 +263,17 @@ class BoincPrivateMessage {
$db = BoincDb::get();
return $db->delete($this, 'private_messages');
}
+ function delete_aux($clause) {
+ $db = BoincDb::get();
+ return $db->delete_aux('private_messages', $clause);
+ }
+}
+
+class BoincPlatform {
+ static function enum($clause) {
+ $db = BoincDb::get();
+ return $db->enum('platform', 'BoincPlatform', $clause);
+ }
}
?>
diff --git a/html/inc/db.inc b/html/inc/db.inc
index d21278dbd5..3dc33e17c8 100644
--- a/html/inc/db.inc
+++ b/html/inc/db.inc
@@ -34,6 +34,7 @@ function db_init_aux($try_replica=false) {
}
function lookup_user_auth($auth) {
+ $auth = BoincDb::escape_string($auth);
return BoincUser::lookup("authenticator='$auth'");
}
@@ -42,10 +43,12 @@ function lookup_user_id($id) {
}
function lookup_user_email_addr($email_addr) {
- return BoincUser::lookup("email_addr='$email_addr'");
+ $e = BoincDb::escape_string($email_addr);
+ return BoincUser::lookup("email_addr='$e'");
}
function lookup_user_name($name) {
+ $name = BoincDb::escape_string($name);
$users = BoincUser::enum("name='".boinc_real_escape_string($name)."'");
if (sizeof($users)==1) {
return $users[0];
@@ -66,6 +69,7 @@ function lookup_team_founder($id) {
}
function lookup_team_name($name) {
+ $name = BoincDb::escape_string($name);
return BoincTeam::lookup("name='$name'");
}
diff --git a/html/inc/db_conn.inc b/html/inc/db_conn.inc
index 77a2a4cf95..58bbc14444 100644
--- a/html/inc/db_conn.inc
+++ b/html/inc/db_conn.inc
@@ -119,6 +119,9 @@ class DbConn {
function base_escape_string($string) {
return mysql_real_escape_string($string, $this->db_conn);
}
+ function base_error() {
+ return mysql_error($this->db_conn);
+ }
}
?>
diff --git a/html/inc/pm.inc b/html/inc/pm.inc
index 775a0b62ca..6e0db3436e 100644
--- a/html/inc/pm.inc
+++ b/html/inc/pm.inc
@@ -101,7 +101,7 @@ function pm_send($to, $subject, $content) {
function pm_count($userid, $duration) {
$time = time() - $duration;
- return PrivateMessage::count("senderid=$userid AND date>$time");
+ return BoincPrivateMessage::count("senderid=$userid AND date>$time");
}
function check_pm_count($userid) {
diff --git a/html/user/account_finish_action.php b/html/user/account_finish_action.php
index d3ade2be6f..34bf481d37 100644
--- a/html/user/account_finish_action.php
+++ b/html/user/account_finish_action.php
@@ -7,7 +7,7 @@ include_once("../inc/email.inc");
function show_error($str) {
page_head("Can't update account");
echo "$str
\n";
- echo mysql_error();
+ echo BoincDb::error();
echo "
Click your browser's Back button to try again.\n
\n";
page_tail();
exit();
diff --git a/html/user/am_set_info.php b/html/user/am_set_info.php
index 87180c74cf..f8c844aa64 100644
--- a/html/user/am_set_info.php
+++ b/html/user/am_set_info.php
@@ -137,7 +137,7 @@ if (strlen($query)) {
if ($result) {
success("");
} else {
- xml_error(-1, "database error: ".mysql_error());
+ xml_error(-1, "database error: ".BoincDb::error());
}
} else {
success("");
diff --git a/html/user/apps.php b/html/user/apps.php
index d98fbf26ae..88b263c2b3 100644
--- a/html/user/apps.php
+++ b/html/user/apps.php
@@ -1,19 +1,12 @@
deprecated) continue;
- array_push($platforms, $platform);
-}
-mysql_free_result($r2);
+$platforms = BoincPlatform::enum("deprecated=0");
$xml = $_GET['xml'];
if ($xml) {
@@ -26,10 +19,10 @@ if ($xml) {
";
start_table();
}
-$result = mysql_query("select * from app where deprecated=0");
+$apps = BoincApp::enum("deprecated=0");
-while ($app = mysql_fetch_object($result)) {
+foreach ($apps as $app) {
if ($xml) {
echo "
Click your browser's Back button to try again.\n
\n";
page_tail();
exit();
@@ -25,7 +25,6 @@ if (parse_bool($config, "disable_account_creation")) {
exit();
}
-db_init();
init_session();
// see whether the new account should be pre-enrolled in a team,
diff --git a/html/user/delete_profile.php b/html/user/delete_profile.php
index 3d1cccfa63..be0a12d6f6 100644
--- a/html/user/delete_profile.php
+++ b/html/user/delete_profile.php
@@ -1,9 +1,8 @@
id");
+ BoincProfile::delete_aux("userid = $user->id");
if ($result) {
delete_user_pictures($user->id);
page_head("Delete Confirmation");
- mysql_query("update user set has_profile=0 where id=$user->id");
+ $user->update("has_profile=0");
echo "Your profile has been deleted
";
} else {
diff --git a/html/user/edit_email_action.php b/html/user/edit_email_action.php
index 1d362964ab..b0a3307c45 100644
--- a/html/user/edit_email_action.php
+++ b/html/user/edit_email_action.php
@@ -1,11 +1,10 @@
id";
- $result = mysql_query($query);
+ $result = $user->update("email_addr='$email_addr', passwd_hash='$passwd_hash'");
if ($result) {
echo "
The email address of your account is now $email_addr.
diff --git a/html/user/edit_passwd_action.php b/html/user/edit_passwd_action.php
index 28465b4c8b..b4947b4fbe 100644
--- a/html/user/edit_passwd_action.php
+++ b/html/user/edit_passwd_action.php
@@ -1,11 +1,9 @@
email_addr);
-$query = "update user set passwd_hash='$passwd_hash' where id=$user->id";
-$result = mysql_query($query);
+$result = $user->update("passwd_hash='$passwd_hash'");
if ($result) {
echo "Your password has been changed.";
} else {
diff --git a/html/user/edit_user_info_action.php b/html/user/edit_user_info_action.php
index f1c72aeb7c..e147f7dd00 100644
--- a/html/user/edit_user_info_action.php
+++ b/html/user/edit_user_info_action.php
@@ -1,11 +1,10 @@
id");
+$result = $user->update("name='$name', url='$url', country='$country', postal_code='$postal_code'");
if ($result) {
Header("Location: home.php");
} else {
diff --git a/html/user/forum_edit.php b/html/user/forum_edit.php
index bc258d9c39..16120735b1 100644
--- a/html/user/forum_edit.php
+++ b/html/user/forum_edit.php
@@ -47,7 +47,7 @@ if (post_str('submit',true) && (!$preview)) {
$add_signature = 0;
}
$content = substr($content, 0, 64000);
- $content = mysql_real_escape_string($content);
+ $content = BoincDb::escape_string($content);
$post->update("signature=$add_signature, content='$content'");
// If this post belongs to the creator of the thread and is at top-level
@@ -58,7 +58,7 @@ if (post_str('submit',true) && (!$preview)) {
$t = post_str('title');
$t = trim($t);
$t = strip_tags($ts);
- $t = mysql_real_escape_string($t);
+ $t = BoincDb::escape_string($t);
$thread->update("title='$t'");
}
diff --git a/html/user/forum_get_data.php b/html/user/forum_get_data.php
index 93f92c72f2..432efb3b72 100644
--- a/html/user/forum_get_data.php
+++ b/html/user/forum_get_data.php
@@ -1,88 +1,75 @@
50) { $count = 10; }
$length = get_int("contentlength", true);
if (($length == null) || ($length <= 0)) { $length = 0; }
- $res = mysql_query("SELECT * FROM post WHERE user=$userid ORDER BY timestamp DESC LIMIT $count");
- if ($res) {
- $count = mysql_num_rows($res);
+ $posts = BoincPost::enum("user=$userid ORDER BY timestamp DESC LIMIT $count");
+ $count = count($posts);
+ echo "
User name | Joined project | @@ -28,12 +25,11 @@ echo "
---|
Recent credit | "; $n = 0; -while ($profile = mysql_fetch_object($result)) { +foreach($profiles as $profile) { show_profile_link($profile, $n+$offset+1); $n += 1; } echo "
---|