mirror of https://github.com/BOINC/boinc.git
- user web: update other code to use new-style DB interfaces
svn path=/trunk/boinc/; revision=14164
This commit is contained in:
parent
a18dfc55a7
commit
0616e75a02
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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'");
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -7,7 +7,7 @@ include_once("../inc/email.inc");
|
|||
function show_error($str) {
|
||||
page_head("Can't update account");
|
||||
echo "$str<br>\n";
|
||||
echo mysql_error();
|
||||
echo BoincDb::error();
|
||||
echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
|
||||
page_tail();
|
||||
exit();
|
||||
|
|
|
@ -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("");
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/translation.inc");
|
||||
|
||||
init_session();
|
||||
db_init();
|
||||
|
||||
$platforms = array();
|
||||
$r2 = mysql_query("select * from platform");
|
||||
while ($platform = mysql_fetch_object($r2)) {
|
||||
if ($platform->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 "<application>\n";
|
||||
echo " <name>$app->user_friendly_name</name>\n";
|
||||
|
@ -42,9 +35,8 @@ while ($app = mysql_fetch_object($result)) {
|
|||
for ($i=0; $i<sizeof($platforms); $i++) {
|
||||
$platform = $platforms[$i];
|
||||
$newest = null;
|
||||
$r2 = mysql_query("select * from app_version where appid=$app->id and platformid = $platform->id");
|
||||
while ($av = mysql_fetch_object($r2)) {
|
||||
if ($av->deprecated) continue;
|
||||
$avs = BoincAppVersion::enum("appid=$app->id and platformid = $platform->id and deprecated=0");
|
||||
foreach($avs as $av) {
|
||||
if (!$newest || $av->version_num>$newest->version_num) {
|
||||
$newest = $av;
|
||||
}
|
||||
|
@ -74,7 +66,7 @@ while ($app = mysql_fetch_object($result)) {
|
|||
echo " </application>\n";
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
|
||||
if ($xml) {
|
||||
echo "</app_versions>\n";
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
include_once("../inc/db.inc");
|
||||
include_once("../inc/boinc_db.inc");
|
||||
include_once("../inc/util.inc");
|
||||
include_once("../inc/email.inc");
|
||||
include_once("../inc/user.inc");
|
||||
|
@ -8,7 +8,7 @@ include_once("../inc/user.inc");
|
|||
function show_error($str) {
|
||||
page_head("Can't create account");
|
||||
echo "$str<br>\n";
|
||||
echo mysql_error();
|
||||
echo BoincDb::error();
|
||||
echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\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,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/profile.inc");
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
|
||||
if (isset($_POST['delete']) && $_POST['delete']) {
|
||||
|
@ -32,11 +31,11 @@ echo "
|
|||
page_tail();
|
||||
|
||||
function delete_profile($user) {
|
||||
$result = mysql_query("DELETE FROM profile WHERE userid = $user->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<br>";
|
||||
} else {
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/email.inc");
|
||||
require_once("../inc/user.inc");
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
|
||||
$email_addr = strtolower(process_user_text(post_str("email_addr")));
|
||||
|
@ -35,8 +34,7 @@ if (!is_valid_email_addr($email_addr)) {
|
|||
echo "Invalid password.";
|
||||
} else {
|
||||
$passwd_hash = md5($passwd.$email_addr);
|
||||
$query = "update user set email_addr='$email_addr', passwd_hash='$passwd_hash' where id=$user->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.
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/user.inc");
|
||||
|
||||
db_init();
|
||||
|
||||
$auth = process_user_text(post_str("auth", true));
|
||||
$email_addr = strtolower(process_user_text(post_str("email_addr", true)));
|
||||
|
||||
|
@ -52,8 +50,7 @@ if ($auth) {
|
|||
|
||||
page_head("Change password");
|
||||
$passwd_hash = md5($passwd.$user->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 {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/user.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/countries.inc");
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
|
||||
$name = boinc_htmlentities(process_user_text(post_str("user_name")));
|
||||
|
@ -27,7 +26,7 @@ if (!is_valid_country($country)) {
|
|||
$postal_code = process_user_text(post_str("postal_code",true));
|
||||
$postal_code = strip_tags($postal_code);
|
||||
|
||||
$result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code' where id=$user->id");
|
||||
$result = $user->update("name='$name', url='$url', country='$country', postal_code='$postal_code'");
|
||||
if ($result) {
|
||||
Header("Location: home.php");
|
||||
} else {
|
||||
|
|
|
@ -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'");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,88 +1,75 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/forum_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/xml.inc");
|
||||
|
||||
// TODO: convert this
|
||||
|
||||
xml_header();
|
||||
|
||||
$retval = db_init_xml();
|
||||
if ($retval) xml_error($retval);
|
||||
|
||||
$method = get_str("method", true);
|
||||
if ($method != "user_posts" && $method != "user_threads") { xml_error(-210); }
|
||||
if ($method != "user_posts" && $method != "user_threads") {
|
||||
xml_error(-210);
|
||||
}
|
||||
|
||||
$userid = get_int("userid", true);
|
||||
$user = lookup_user_id($userid);
|
||||
if (!$user) {
|
||||
xml_error(-136);
|
||||
}
|
||||
|
||||
if ($method == "user_posts") {
|
||||
$userid = get_int("userid", true);
|
||||
$user = lookup_user_id($userid);
|
||||
if (!$user) { xml_error(-136); }
|
||||
|
||||
$count = get_int("count", true);
|
||||
if (!$count || $count <= 0 || $count > 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 "<rpc_response>\n";
|
||||
echo "<count>$count</count>\n";
|
||||
echo "<posts>\n";
|
||||
|
||||
echo "<rpc_response>\n";
|
||||
echo "<count>$count</count>\n";
|
||||
echo "<posts>\n";
|
||||
|
||||
while ($row = mysql_fetch_object($res)) {
|
||||
$thread = mysql_query("SELECT * FROM thread WHERE id=".$row->thread);
|
||||
$thread = mysql_fetch_object($thread);
|
||||
echo "<post>\n";
|
||||
echo " <id>$row->id</id>\n";
|
||||
echo " <threadid>$row->thread</threadid>\n";
|
||||
echo " <threadtitle><![CDATA[".$thread->title."]]></threadtitle>\n";
|
||||
echo " <timestamp>$row->timestamp</timestamp>\n";
|
||||
if ($length > 0) {
|
||||
echo " <content><![CDATA[".substr($row->content, 0, $length)."]]></content>\n";
|
||||
} else {
|
||||
echo " <content><![CDATA[".$row->content."]]></content>\n";
|
||||
}
|
||||
echo "</post>\n";
|
||||
foreach ($posts as $post) {
|
||||
$thread = BoincThread::lookup_id($post->thread);
|
||||
echo "<post>\n";
|
||||
echo " <id>$post->id</id>\n";
|
||||
echo " <threadid>$post->thread</threadid>\n";
|
||||
echo " <threadtitle><![CDATA[".$thread->title."]]></threadtitle>\n";
|
||||
echo " <timestamp>$post->timestamp</timestamp>\n";
|
||||
if ($length > 0) {
|
||||
echo " <content><![CDATA[".substr($post->content, 0, $length)."]]></content>\n";
|
||||
} else {
|
||||
echo " <content><![CDATA[".$post->content."]]></content>\n";
|
||||
}
|
||||
|
||||
echo "</posts>\n";
|
||||
echo "</rpc_response>\n";
|
||||
} else {
|
||||
xml_error(-1, "Database error");
|
||||
echo "</post>\n";
|
||||
}
|
||||
|
||||
echo "</posts>\n";
|
||||
echo "</rpc_response>\n";
|
||||
} elseif ($method == "user_threads") {
|
||||
|
||||
$userid = get_int("userid", true);
|
||||
$user = lookup_user_id($userid);
|
||||
if (!$user) { xml_error(-136); }
|
||||
|
||||
$count = get_int("count", true);
|
||||
if (!$count || $count <= 0 || $count > 50) { $count = 10; }
|
||||
$res = mysql_query("SELECT * FROM thread WHERE owner=$userid ORDER BY timestamp DESC LIMIT $count");
|
||||
if ($res) {
|
||||
$count = mysql_num_rows($res);
|
||||
$threads = BoincThread::enum("owner=$userid ORDER BY timestamp DESC LIMIT $count");
|
||||
$count = count($threads);
|
||||
|
||||
echo "<rpc_response>\n";
|
||||
echo "<count>$count</count>\n";
|
||||
echo "<threads>\n";
|
||||
while ($row = mysql_fetch_object($res)) {
|
||||
echo "<thread>\n";
|
||||
echo " <id>$row->id</id>\n";
|
||||
echo " <forumid>$row->forum</forumid>\n";
|
||||
echo " <replies>$row->replies</replies>\n";
|
||||
echo " <views>$row->views</views>\n";
|
||||
echo " <timestamp>$row->timestamp</timestamp>\n";
|
||||
echo " <title><![CDATA[$row->title]]></title>\n";
|
||||
echo "</thread>\n";
|
||||
}
|
||||
|
||||
echo "</threads>\n";
|
||||
echo "</rpc_response>\n";
|
||||
} else {
|
||||
xml_error(-1, "Database error");
|
||||
echo "<rpc_response>\n";
|
||||
echo "<count>$count</count>\n";
|
||||
echo "<threads>\n";
|
||||
foreach($threads as $thread) {
|
||||
echo "<thread>\n";
|
||||
echo " <id>$thread->id</id>\n";
|
||||
echo " <forumid>$thread->forum</forumid>\n";
|
||||
echo " <replies>$thread->replies</replies>\n";
|
||||
echo " <views>$thread->views</views>\n";
|
||||
echo " <timestamp>$thread->timestamp</timestamp>\n";
|
||||
echo " <title><![CDATA[$thread->title]]></title>\n";
|
||||
echo "</thread>\n";
|
||||
}
|
||||
|
||||
echo "</threads>\n";
|
||||
echo "</rpc_response>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/user.inc");
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/forum.inc");
|
||||
|
||||
// show the home page of whoever's logged in
|
||||
// show the home page of logged-in user
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
$user = getForumPreferences($user);
|
||||
BoincForumPrefs::lookup($user);
|
||||
$user = get_other_projects($user);
|
||||
|
||||
$init = isset($_COOKIE['init']);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/email.inc");
|
||||
require_once("../inc/user.inc");
|
||||
|
||||
init_session();
|
||||
db_init();
|
||||
|
||||
$mode = post_str("mode", true);
|
||||
|
||||
// First check for email/password case
|
||||
//
|
||||
$email_addr = strtolower(process_user_text(post_str("email_addr", true)));
|
||||
$passwd = stripslashes(post_str("passwd", true));
|
||||
if ($mode == "Log in with email/password") {
|
||||
|
@ -60,16 +60,11 @@ if (!$authenticator) {
|
|||
error_page("You must supply an account key");
|
||||
}
|
||||
|
||||
$query = "select * from user where authenticator='$authenticator'";
|
||||
$result = mysql_query($query);
|
||||
if ($result) {
|
||||
$user = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
}
|
||||
if (substr($user->authenticator, 0, 1) == 'x'){
|
||||
//User has been bad so we are going to take away ability to post for awhile.
|
||||
error_page("This account has been administratively disabled.");
|
||||
}
|
||||
$user = lookup_user_auth($authenticator);
|
||||
if (!$user) {
|
||||
page_head("Log in");
|
||||
echo "
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// RPC handler for account lookup
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/email.inc");
|
||||
require_once("../inc/xml.inc");
|
||||
|
@ -14,7 +14,8 @@ if ($retval) xml_error($retval);
|
|||
$email_addr = get_str("email_addr");
|
||||
$passwd_hash = process_user_text(get_str("passwd_hash", true));
|
||||
|
||||
$user = lookup_user_email_addr($email_addr);
|
||||
$email_addr = BoincDb::escape_string($email_addr);
|
||||
$user = BoincUser::lookup("email_addr='$email_addr');
|
||||
if (!$user) {
|
||||
xml_error(-136);
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ $auth_hash = md5($user->authenticator.$user->email_addr);
|
|||
//
|
||||
if (!strlen($user->passwd_hash)) {
|
||||
$user->passwd_hash = $auth_hash;
|
||||
mysql_query("update user set passwd_hash='$user->passwd_hash' where id=$user->id");
|
||||
$user->update(passwd_hash='$user->passwd_hash'");
|
||||
}
|
||||
|
||||
// if the given password hash matches (auth+email), accept it
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/user.inc");
|
||||
require_once("../inc/db.inc");
|
||||
|
||||
db_init();
|
||||
require_once("../inc/boinc_db.inc");
|
||||
|
||||
$code = get_str("code");
|
||||
$userid = get_int('userid');
|
||||
|
@ -16,15 +14,17 @@ if (salted_key($user->authenticator) != $code) {
|
|||
error_page("bad code");
|
||||
}
|
||||
|
||||
$result = mysql_query("update user set send_email=0 where id=$userid");
|
||||
$result = $user->update("send_email=0");
|
||||
|
||||
page_head("$email removed from mailing list");
|
||||
if ($result) {
|
||||
page_head("$email removed from mailing list");
|
||||
echo "
|
||||
No further emails will be sent to $user->email_addr.
|
||||
To resume getting emails,
|
||||
go <a href=".URL_BASE."/prefs_edit.php?subset=project>here</a>
|
||||
";
|
||||
page_tail();
|
||||
}
|
||||
error_page("database error");
|
||||
|
||||
echo "
|
||||
No further emails will be sent to $user->email_addr.
|
||||
To resume getting emails,
|
||||
go <a href=".URL_BASE."/prefs_edit.php?subset=project>here</a>
|
||||
";
|
||||
|
||||
page_tail();
|
||||
?>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/email.inc");
|
||||
require_once("../inc/pm.inc");
|
||||
require_once("../inc/forum.inc");
|
||||
|
@ -52,7 +53,7 @@ function do_inbox($logged_in_user) {
|
|||
}
|
||||
$options = new output_options;
|
||||
|
||||
$msgs = BoincPrivateMessages::enum(
|
||||
$msgs = BoincPrivateMessage::enum(
|
||||
"userid=$logged_in_user->id ORDER BY date DESC"
|
||||
);
|
||||
if (count($msgs) == 0) {
|
||||
|
@ -135,14 +136,16 @@ function do_new($logged_in_user) {
|
|||
|
||||
function do_delete($logged_in_user) {
|
||||
$id = get_int("id", true);
|
||||
if ($id == null) { $id = post_int("id"); }
|
||||
if ($id == null) {
|
||||
$id = post_int("id");
|
||||
}
|
||||
check_tokens($logged_in_user->authenticator);
|
||||
mysql_query("DELETE FROM private_messages WHERE userid=".$logged_in_user->id." AND id=$id");
|
||||
BoincPrivateMessage::delete_aux("userid=".$logged_in_user->id." AND id=$id");
|
||||
header("Location: pm.php");
|
||||
}
|
||||
|
||||
function do_send($logged_in_user) {
|
||||
check_banished(new User($logged_in_user->id));
|
||||
check_banished($logged_in_user);
|
||||
check_tokens($logged_in_user->authenticator);
|
||||
|
||||
$to = stripslashes(post_str("to", true));
|
||||
|
@ -155,7 +158,7 @@ function do_send($logged_in_user) {
|
|||
if (($to == null) || ($subject == null) || ($content == null)) {
|
||||
pm_create_new(tra("You need to fill all fields to send a private message"));
|
||||
} else {
|
||||
akismet_check(new User($logged_in_user->id), $content);
|
||||
akismet_check($logged_in_user, $content);
|
||||
$to = str_replace(", ", ",", $to); // Filter out spaces after separator
|
||||
$users = explode(",", $to);
|
||||
|
||||
|
@ -233,7 +236,7 @@ function do_confirmedblock($logged_in_user) {
|
|||
function do_delete_selected($logged_in_user) {
|
||||
check_tokens($logged_in_user->authenticator);
|
||||
foreach ($_POST["pm_select"] as $id) {
|
||||
$id = mysql_real_escape_string($id);
|
||||
$id = BoincDb::escape_string($id);
|
||||
$msg = BoincPrivateMessage::lookup_id($id);
|
||||
if ($msg && $msg->userid == $logged_in_user->id) {
|
||||
$msg->delete();
|
||||
|
@ -245,7 +248,7 @@ function do_delete_selected($logged_in_user) {
|
|||
function do_mark_as_read_selected($logged_in_user) {
|
||||
check_tokens($logged_in_user->authenticator);
|
||||
foreach ($_POST["pm_select"] as $id) {
|
||||
$id = mysql_real_escape_string($id);
|
||||
$id = BoincDb::escape_string($id);
|
||||
$msg = BoincPrivateMessage::lookup_id($id);
|
||||
if ($msg && $msg->userid == $logged_in_user->id) {
|
||||
$msg->update("opened=1");
|
||||
|
@ -257,7 +260,7 @@ function do_mark_as_read_selected($logged_in_user) {
|
|||
function do_mark_as_unread_selected($logged_in_user) {
|
||||
check_tokens($logged_in_user->authenticator);
|
||||
foreach ($_POST["pm_select"] as $id) {
|
||||
$id = mysql_real_escape_string($id);
|
||||
$id = BoincDb::escape_string($id);
|
||||
$msg = BoincPrivateMessage::lookup_id($id);
|
||||
if ($msg && $msg->userid == $logged_in_user->id) {
|
||||
$msg->update("opened=0");
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/profile.inc");
|
||||
|
||||
db_init();
|
||||
require_once("../inc/boinc_db.inc");
|
||||
|
||||
$userid = $_GET['userid'];
|
||||
$vote = $_GET['vote'];
|
||||
|
@ -12,7 +10,7 @@ if ($vote != "recommend" && $vote != "reject") {
|
|||
exit();
|
||||
}
|
||||
|
||||
mysql_query("UPDATE profile SET $vote=$vote+1 WHERE userid = $userid");
|
||||
BoincProfile::update_aux("$vote=$vote+1 WHERE userid = $userid");
|
||||
|
||||
page_head("Vote Recorded");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
|
||||
function show_profile_link($profile, $n) {
|
||||
|
@ -8,8 +8,6 @@ function show_profile_link($profile, $n) {
|
|||
echo "<tr><td align=\"center\">".user_links($user)."</td><td align=\"center\">".date_str($user->create_time)."</td><td align=\"center\">".$user->country."</td><td align=\"center\">".(int)$user->total_credit."</td><td align=\"center\">".(int)$user->expavg_credit."</td></tr>\n";
|
||||
}
|
||||
|
||||
db_init();
|
||||
|
||||
$search_string = get_str('search_string');
|
||||
$offset = get_int('offset', true);
|
||||
if (!$offset) $offset=0;
|
||||
|
@ -18,8 +16,7 @@ $count = 10;
|
|||
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);
|
||||
$profiles = BoincProfile::enum("match(response1, response2) against ('$search_string') limit $offset,$count");
|
||||
echo "<table align=\"center\" cellpadding=\"1\" border=\"1\" width=\"90%\">
|
||||
<tr><th align=\"center\">User name</th>
|
||||
<th align=\"center\">Joined project</th>
|
||||
|
@ -28,12 +25,11 @@ echo "<table align=\"center\" cellpadding=\"1\" border=\"1\" width=\"90%\">
|
|||
<th align=\"center\">Recent credit</th></tr>
|
||||
";
|
||||
$n = 0;
|
||||
while ($profile = mysql_fetch_object($result)) {
|
||||
foreach($profiles as $profile) {
|
||||
show_profile_link($profile, $n+$offset+1);
|
||||
$n += 1;
|
||||
}
|
||||
echo "</table>";
|
||||
mysql_free_result($result);
|
||||
|
||||
if ($offset==0 && $n==0) {
|
||||
echo "No profiles found containing '$search_string'";
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
// show recent results for a host or user
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/result.inc");
|
||||
|
||||
|
@ -12,14 +13,13 @@ if (!parse_bool($config, "show_results")) {
|
|||
|
||||
$results_per_page = 20;
|
||||
|
||||
db_init();
|
||||
$hostid = get_int("hostid", true);
|
||||
$userid = get_int("userid", true);
|
||||
$offset = get_int("offset", true);
|
||||
if (!$offset) $offset=0;
|
||||
|
||||
if ($hostid) {
|
||||
$host = lookup_host($hostid);
|
||||
$host = BoincHost::lookup_id($hostid);
|
||||
$type = "computer";
|
||||
$clause = "hostid=$hostid";
|
||||
} else {
|
||||
|
@ -33,17 +33,17 @@ if ($hostid) {
|
|||
page_head("Tasks for $type");
|
||||
result_table_start(true, false, true);
|
||||
$i = 0;
|
||||
$query = "select * from result where $clause order by id desc limit $offset,".($results_per_page+1);
|
||||
$result = mysql_query($query);
|
||||
$number_of_results = mysql_affected_rows();
|
||||
$query = "$clause order by id desc limit $offset,".($results_per_page+1);
|
||||
$results = BoincResult::enum($query);
|
||||
$number_of_results = count($results);
|
||||
echo show_result_navigation(
|
||||
$clause, $number_of_results, $offset, $results_per_page
|
||||
);
|
||||
while ($res = mysql_fetch_object($result) and $i<$results_per_page) {
|
||||
foreach ($results as $result) {
|
||||
if ($i >= $results_per_page) break;
|
||||
show_result_row($res, true, false, true);
|
||||
$i++;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
echo "</table>\n";
|
||||
|
||||
echo show_result_navigation(
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/email.inc");
|
||||
|
||||
db_init();
|
||||
|
||||
function send_validate_email() {
|
||||
global $master_url;
|
||||
$user = get_logged_in_user();
|
||||
|
@ -38,7 +36,7 @@ function validate() {
|
|||
error_page("Error in URL data - can't validate email address");
|
||||
}
|
||||
|
||||
$result = mysql_query("update user set email_validated=1 where id=$user->id");
|
||||
$result = $user->update("email_validated=1");
|
||||
if (!$result) {
|
||||
error_page("Database update failed - please try again later.");
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
// show summary of a workunit
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/boinc_db.inc");
|
||||
require_once("../inc/result.inc");
|
||||
|
||||
db_init();
|
||||
$wuid = get_int("wuid");
|
||||
$wu = lookup_wu($wuid);
|
||||
$wu = BoincWorkunit::lookup_id($wuid);
|
||||
if (!$wu) {
|
||||
error_page("can't find workunit");
|
||||
}
|
||||
|
||||
page_head("Workunit details");
|
||||
$app = lookup_app($wu->appid);
|
||||
$app = BoincApp::lookup_id($wu->appid);
|
||||
|
||||
start_table();
|
||||
row2("application", $app->user_friendly_name);
|
||||
|
@ -37,11 +37,10 @@ end_table();
|
|||
project_workunit($wu);
|
||||
|
||||
result_table_start(false, true, true);
|
||||
$result = mysql_query("select * from result where workunitid=$wuid");
|
||||
while ($res = mysql_fetch_object($result)) {
|
||||
$results = BoincResult::enum("workunitid=$wuid");
|
||||
foreach ($results as $result) {
|
||||
show_result_row($res, false, true, true);
|
||||
}
|
||||
mysql_free_result($result);
|
||||
echo "</table>\n";
|
||||
page_tail();
|
||||
|
||||
|
|
Loading…
Reference in New Issue