*** empty log message ***

svn path=/trunk/boinc/; revision=3727
This commit is contained in:
David Anderson 2004-06-30 18:53:35 +00:00
parent 7ab5c16f17
commit cd3884593b
14 changed files with 97 additions and 33 deletions

View File

@ -14330,6 +14330,31 @@ Karl 2004-06-30
boinc_setup.vdproj
boinc_setup_auto.vdproj
David 30 June 2004
- PHP code: change parse_config() so that it doesn't
read the config file; you have to read it first into a variable
(using get_config()) and pass it in to parse_config()
This saves work when you want to look at several config params.
- db_init(): parse the DB hostname and use it in mysql_connect.
This lets you run the web site from a different host than DB
- disallow caching of top_* pages with random offsets
- change cache period of top_* pages to 12 hours
- fix bug in user name search (escape _, %)
html/
inc/
db.inc
db_ops.inc
util.inc
user/
create_account_action.php
create_account_form.php
profile_menu.php
sample_rss_main.php
top_hosts.php
top_teams.php
top_users.php
Eric K 30 June 2004
- Removed "using" directives from header files. "using"
directives should not be used in header files for the following reasons.
@ -14346,3 +14371,11 @@ Eric K 30 June 2004
won't affect other files. It's better to have "using std::string;"
directives than "using namespace std;" for hopefully obvious reasons.
David 30 June 2004
- change feeder query to eliminate 'order by random'
and add a limit of 100.
- change db_dump to not get counts, since these are slow on InnoDB
sched/
db_dump.C
feeder.C

View File

@ -10,15 +10,20 @@ function db_init() {
echo "Project is shut down for maintenance - please try again later\n";
exit();
}
$user = parse_config("<db_user>");
$pass = parse_config("<db_passwd>");
$retval = mysql_pconnect("localhost", $user, $pass);
$config = get_config();
$user = parse_config($config, "<db_user>");
$pass = parse_config($config, "<db_passwd>");
$host = parse_config($config, "<db_host>");
if ($host == null) {
$host = "localhost";
}
$retval = mysql_pconnect($host, $user, $pass);
if (!$retval) {
echo "Unable to connect to database - please try again later\n";
echo "Error: ", mysql_errno(), mysql_error();
exit();
}
$db_name = parse_config("<db_name>");
$db_name = parse_config($config, "<db_name>");
if(!mysql_select_db($db_name)) {
echo "Unable to select database - please try again later";
echo mysql_error();

View File

@ -1,15 +1,20 @@
<?php
function db_init() {
$user = parse_config("<db_user>");
$pass = parse_config("<db_passwd>");
$retval = mysql_connect("localhost", $user, $pass);
$config = get_config();
$user = parse_config($config, "<db_user>");
$pass = parse_config($config, "<db_passwd>");
$host = parse_config($config, "<db_host>");
if ($host == null) {
$host = "localhost";
}
$retval = mysql_connect($host, $user, $pass);
if (!$retval) {
echo "Unable to connect to database - please try again later";
echo mysql_error();
exit();
}
$db_name = parse_config("<db_name>");
$db_name = parse_config($config, "<db_name>");
if(!mysql_select_db($db_name)) {
echo "Unable to select database '$db_name' - please try again later";
echo mysql_error();

View File

@ -272,12 +272,14 @@ function file_get_contents($path) {
}
}
function get_config() {
return file_get_contents("../../config.xml");
}
// look for a particular element in the ../../config.xml file
//
function parse_config($tag) {
$element = null;
$buf = file_get_contents("../../config.xml");
$element = parse_element($buf, $tag);
function parse_config($config, $tag) {
$element = parse_element($config, $tag);
return trim($element);
}

View File

@ -12,7 +12,8 @@ function show_error($str) {
exit();
}
if (parse_config("<disable_account_creation/>")) {
$config = get_config();
if (parse_config($config, "<disable_account_creation/>")) {
page_head("Account creation is disabled");
echo "
<h3>Account creation is disabled</h3>

View File

@ -6,7 +6,8 @@ require_once('../inc/countries.inc');
db_init();
page_head('Create an account');
if (parse_config("<disable_account_creation/>")) {
$config = get_config();
if (parse_config($config, "<disable_account_creation/>")) {
echo "
<h1>Account Creation is Disabled</h1>
<p>

View File

@ -106,7 +106,6 @@ function execute_command($cmd) {
header("Location: " . URL_BASE . "view_profile.php?userid=" . $userIds[0]);
exit();
}
}
?>

View File

@ -31,7 +31,7 @@ require_once("../project/project_news.inc");
// Create channel header and open XML content
//
$description = "BOINC project ".PROJECT.": Main page News";
$channel_image = MASTER_URL . "rss_image.jpg";
$channel_image = MASTER_URL . "/rss_image.jpg";
$create_date = gmdate('D, d M Y H:i:s') . ' GMT';
$language = "en-us";
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"

View File

@ -1,16 +1,19 @@
<?php
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
$n = 20;
$sort_by = $_GET["sort_by"];
if (!$sort_by) $sort_by = "expavg_credit";
$offset = $_GET["offset"];
if (!$offset) $offset=0;
// don't cache offsets over 1000. prevents DOS attack
//
if ($offset % $n) $offset = 0;
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(3600, $cache_args);
start_cache(12*3600, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";
@ -18,12 +21,9 @@
}
require_once("../inc/util.inc");
require_once("../inc/db.inc");
require_once("../inc/host.inc");
$n = 20;
db_init();
page_head("Top computers");
if ($sort_by == "total_credit") {

View File

@ -1,13 +1,19 @@
<?php {
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
$n = 20;
$sort_by = $_GET["sort_by"];
if (!$sort_by) $sort_by = "expavg_credit";
$offset = $_GET["offset"];
if (!$offset) $offset=0;
if ($offset % $n) $offset = 0;
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(3600, $cache_args);
start_cache(12*3600, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";
@ -16,12 +22,9 @@
}
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/user.inc");
require_once("../inc/team.inc");
$n = 20;
db_init();
page_head("Top teams");

View File

@ -1,26 +1,28 @@
<?php {
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
$n = 20;
$sort_by = $_GET["sort_by"];
if (!$sort_by) $sort_by = "expavg_credit";
$offset = $_GET["offset"];
if (!$offset) $offset=0;
if ($offset % $n) $offset = 0;
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(3600, $cache_args);
start_cache(12*3600, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";
page_tail();
}
require_once("../inc/util.inc");
require_once("../inc/db.inc");
require_once("../inc/user.inc");
$n = 20;
db_init();
page_head("Top participants");
if ($sort_by == "total_credit") {

View File

@ -17,6 +17,10 @@ $count = 10;
page_head("Search results");
echo "<h2>User names containing '$search_string'</h2>\n";
$search_string = str_replace('_', '\\\\_', $search_string);
$search_string = str_replace('%', '\\\\%', $search_string);
$q = "select * from user where name like '$search_string%' limit $offset,$count";
$result = mysql_query($q);
echo "<table>";

View File

@ -549,6 +549,9 @@ int print_app(FILE* f, APP& app) {
fprintf(f, " <application>\n");
fprintf(f, " <name>%s</name>\n", app.user_friendly_name);
#if 0
// can't do this stuff because MySQL/InnoDB can't do counts efficiently
//
sprintf(buf, "where appid=%d and server_state=%d", app.id, RESULT_SERVER_STATE_UNSENT);
retval = result.count(n, buf);
if (!retval) {
@ -566,6 +569,7 @@ int print_app(FILE* f, APP& app) {
if (!retval) {
fprintf(f, " <results_over>%d</results_over>\n", n);
}
#endif
fprintf(f, " </application>\n");
return 0;
@ -592,6 +596,12 @@ int tables_file(char* dir) {
ZFILE f("tables", false);
sprintf(buf, "%s/tables.xml", dir);
f.open(buf);
fprintf(f.f,
" <update_time>%d</update_time>\n",
(int)time(0)
);
#if 0
// can't do counts in MySQL/InnoDB
retval = user.count(nusers);
if (retval) return retval;
retval = team.count(nteams);
@ -599,15 +609,14 @@ int tables_file(char* dir) {
retval = host.count(nhosts);
if (retval) return retval;
fprintf(f.f,
" <update_time>%d</update_time>\n"
" <nusers_total>%d</nusers_total>\n"
" <nteams_total>%d</nteams_total>\n"
" <nhosts_total>%d</nhosts_total>\n",
(int)time(0),
nusers,
nteams,
nhosts
);
#endif
print_apps(f.f);
f.close();
return 0;

View File

@ -296,7 +296,7 @@ void feeder_loop() {
bool no_wus;
char clause[256];
sprintf(clause, "where server_state=%d order by random",
sprintf(clause, "where server_state=%d limit 100",
RESULT_SERVER_STATE_UNSENT
);