diff --git a/checkin_notes b/checkin_notes index b72a81116d..26a793b042 100755 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/html/inc/db.inc b/html/inc/db.inc index fa0798514d..22c5990671 100644 --- a/html/inc/db.inc +++ b/html/inc/db.inc @@ -10,15 +10,20 @@ function db_init() { echo "Project is shut down for maintenance - please try again later\n"; exit(); } - $user = parse_config(""); - $pass = parse_config(""); - $retval = mysql_pconnect("localhost", $user, $pass); + $config = get_config(); + $user = parse_config($config, ""); + $pass = parse_config($config, ""); + $host = parse_config($config, ""); + 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 = parse_config($config, ""); if(!mysql_select_db($db_name)) { echo "Unable to select database - please try again later"; echo mysql_error(); diff --git a/html/inc/db_ops.inc b/html/inc/db_ops.inc index 3a3f634709..1c81b7264b 100644 --- a/html/inc/db_ops.inc +++ b/html/inc/db_ops.inc @@ -1,15 +1,20 @@ "); - $pass = parse_config(""); - $retval = mysql_connect("localhost", $user, $pass); + $config = get_config(); + $user = parse_config($config, ""); + $pass = parse_config($config, ""); + $host = parse_config($config, ""); + 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 = parse_config($config, ""); if(!mysql_select_db($db_name)) { echo "Unable to select database '$db_name' - please try again later"; echo mysql_error(); diff --git a/html/inc/util.inc b/html/inc/util.inc index 616bea0de0..333f7129e7 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -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); } diff --git a/html/user/create_account_action.php b/html/user/create_account_action.php index d617ead247..daa1f36ae3 100644 --- a/html/user/create_account_action.php +++ b/html/user/create_account_action.php @@ -12,7 +12,8 @@ function show_error($str) { exit(); } - if (parse_config("")) { + $config = get_config(); + if (parse_config($config, "")) { page_head("Account creation is disabled"); echo "

Account creation is disabled

diff --git a/html/user/create_account_form.php b/html/user/create_account_form.php index b41d6b7061..ea79037891 100644 --- a/html/user/create_account_form.php +++ b/html/user/create_account_form.php @@ -6,7 +6,8 @@ require_once('../inc/countries.inc'); db_init(); page_head('Create an account'); -if (parse_config("")) { +$config = get_config(); +if (parse_config($config, "")) { echo "

Account Creation is Disabled

diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php index 818015e856..e0857d77c6 100644 --- a/html/user/profile_menu.php +++ b/html/user/profile_menu.php @@ -106,7 +106,6 @@ function execute_command($cmd) { header("Location: " . URL_BASE . "view_profile.php?userid=" . $userIds[0]); exit(); } - } ?> diff --git a/html/user/sample_rss_main.php b/html/user/sample_rss_main.php index 84b96090a9..6cba3f3037 100644 --- a/html/user/sample_rss_main.php +++ b/html/user/sample_rss_main.php @@ -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 "\n" diff --git a/html/user/top_hosts.php b/html/user/top_hosts.php index b19a29f96b..c822d1cd58 100644 --- a/html/user/top_hosts.php +++ b/html/user/top_hosts.php @@ -1,16 +1,19 @@ User names containing '$search_string'\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 ""; diff --git a/sched/db_dump.C b/sched/db_dump.C index 1962ff7172..95815c5e41 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -549,6 +549,9 @@ int print_app(FILE* f, APP& app) { fprintf(f, " \n"); fprintf(f, " %s\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, " %d\n", n); } +#endif fprintf(f, " \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, + " %d\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, - " %d\n" " %d\n" " %d\n" " %d\n", - (int)time(0), nusers, nteams, nhosts ); +#endif print_apps(f.f); f.close(); return 0; diff --git a/sched/feeder.C b/sched/feeder.C index 0ac7ffbf10..194a722a7e 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -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 );