Skip to content

Commit 40b9dc0

Browse files
authored
Merge pull request #6975 from BOINC/dpa_web42
parse config.xml with simplexml
2 parents a709539 + a36dc0a commit 40b9dc0

64 files changed

Lines changed: 185 additions & 316 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

html/inc/account.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function create_account_form($teamid, $next_url) {
9090
),
9191
"new_email_addr"
9292
);
93-
$min_passwd_length = parse_element(get_config(), "<min_passwd_length>");
93+
$min_passwd_length = project_config_val('min_passwd_length');
9494
if (!$min_passwd_length) {
9595
$min_passwd_length = 6;
9696
}

html/inc/account_ownership.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ require_once("../inc/boinc_db.inc");
2121
require_once("../inc/user.inc");
2222
require_once("../inc/util.inc");
2323

24-
$temp_config = get_config();
25-
$temp_keydir = parse_config($temp_config, "<key_dir>"); // key directory can be customized
24+
$temp_keydir = project_config_val("key_dir"); // key directory can be customized
2625

2726
$account_ownership_private_key_file_name = "account_ownership_private.pem"; // private key file name
2827
$account_ownership_private_key = "$temp_keydir/$account_ownership_private_key_file_name"; // for overwriting key

html/inc/akismet.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
//
2525
function akismet_check($user, $post) {
2626
$master_url = master_url();
27-
$config = get_config();
28-
$key = parse_config($config, "<akismet_key>");
27+
$key = project_config_val("akismet_key");
2928
if (!$key) {
3029
return true;
3130
}

html/inc/boinc_db.inc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ class BoincDb {
5454
static function get_aux($dbnum) {
5555
$instance = new DbConn();
5656
self::$instance = null;
57-
$config = get_config();
5857
if ($dbnum) {
5958
$r = $dbnum==1?'':strval($dbnum);
60-
$host = parse_config($config, sprintf('<replica%s_db_host>', $r));
61-
$name = parse_config($config, sprintf('<replica%s_db_name>', $r));
62-
$user = parse_config($config, sprintf('<replica%s_db_user>', $r));
63-
$passwd = parse_config($config, sprintf('<replica%s_db_passwd>', $r));
59+
$host = project_config_val(sprintf('replica%s_db_host', $r));
60+
$name = project_config_val(sprintf('replica%s_db_name', $r));
61+
$user = project_config_val(sprintf('replica%s_db_user', $r));
62+
$passwd = project_config_val(sprintf('replica%s_db_passwd', $r));
6463
if ($host && $name && $user && $passwd) {
6564
$retval = $instance->init_conn($user, $passwd, $host, $name);
6665
if ($retval) {
@@ -72,11 +71,11 @@ class BoincDb {
7271
}
7372
// if can't connect to replica, fall through and try DB 0
7473
}
75-
$host = parse_config($config, '<db_host>');
74+
$host = project_config_val('db_host');
7675
if (!$host) $host = 'localhost';
77-
$user = parse_config($config, '<db_user>');
78-
$name = parse_config($config, '<db_name>');
79-
$passwd = parse_config($config, '<db_passwd>');
76+
$user = project_config_val('db_user');
77+
$name = project_config_val('db_name');
78+
$passwd = project_config_val('db_passwd');
8079
if (!$name || !$user || !$passwd) {
8180
error_log("BoincDb::get_aux(): must specify DB name, user, passwd");
8281
return;

html/inc/consent.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ function check_consent_type($name, $checkenabled=TRUE) {
8080
//
8181
function intercept_login($user, $perm, $in_next_url = "") {
8282
list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
83-
$config = get_config();
84-
if (parse_bool($config, "enable_login_mustagree_termsofuse")
83+
if (project_config_bool("enable_login_mustagree_termsofuse")
8584
and $checkct
8685
and check_termsofuse()
8786
and (!check_user_consent($user, CONSENT_TYPE_ENROLL))

html/inc/db.inc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,24 @@ if (MYSQLI) {
151151
}
152152

153153
function db_init_aux($try_replica=false) {
154-
$config = get_config();
155-
$user = parse_config($config, "<db_user>");
156-
$pass = parse_config($config, "<db_passwd>");
157-
$db_name = parse_config($config, "<db_name>");
154+
$user = project_config_val("db_user");
155+
$pass = project_config_val("db_passwd");
156+
$db_name = project_config_val("db_name");
158157
$host = null;
159158
if ($try_replica) {
160-
$x = parse_config($config, "<replica_db_host>");
159+
$x = project_config_val("replica_db_host");
161160
if ($x) {
162161
$host = $x;
163-
$x = parse_config($config, "<replica_db_user>");
162+
$x = project_config_val("replica_db_user");
164163
if ($x) $user = $x;
165-
$x = parse_config($config, "<replica_db_passwd>");
164+
$x = project_config_val("replica_db_passwd");
166165
if ($x) $pass = $x;
167-
$x = parse_config($config, "<replica_db_name>");
166+
$x = project_config_val("replica_db_name");
168167
if ($x) $db_name = $x;
169168
}
170169
}
171170
if (is_blank($host)) {
172-
$host = parse_config($config, "<db_host>");
171+
$host = project_config_val("db_host");
173172
}
174173
if (is_blank($host)) {
175174
$host = "localhost";

html/inc/db_ops.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ function link_results($n, $mq, $query, $clauses) {
396396
// @param String $stderr_out the stderr_out value to parse
397397
//
398398
function stderr_error_string($stderr_out){
399-
$y = parse_element($stderr_out, "<error_code>");
399+
$y = parse_element_text($stderr_out, "<error_code>");
400400
$x = 0;
401401
if ($y) {
402402
$x = (int)$y;
@@ -504,7 +504,7 @@ FROM result WHERE true
504504
// subtract X from mod time of file-deleted results.
505505
// Otherwise we'll show lots of irrelevant results
506506
//
507-
$delay = parse_config(get_config(), "<delete_delay_hours>");
507+
$delay = project_config_val("delete_delay_hours");
508508
if ($delay) {
509509
$start2 = $start - $delay*3600;;
510510
$main_query .= " and ((file_delete_state>1 and mod_time>FROM_UNIXTIME($start2)) or (mod_time>FROM_UNIXTIME($start)))";

html/inc/delete_account.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ function insert_deleted_records($user) {
7272
// and make that a third mechanism if they have a need to
7373
//
7474
function delete_account($user) {
75-
$config = get_config();
76-
$enable_delete_account = parse_config($config, "<enable_delete_account>");
75+
$enable_delete_account = project_config_val("enable_delete_account");
7776
if ($enable_delete_account == DELETE_ACCOUNT_METHOD_OBFUSCATE) {
7877
return obfuscate_account($user);
7978
} else if ($enable_delete_account == DELETE_ACCOUNT_METHOD_WIPE) {

html/inc/dir_hier.inc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ function dir_hier_path($filename, $root, $fanout) {
3939
function upload_path($filename) {
4040
static $upload_dir=null;
4141
if (!$upload_dir) {
42-
$config = get_config();
43-
$upload_dir = parse_config($config, '<upload_dir>');
44-
$uldl_dir_fanout = parse_config($config, '<uldl_dir_fanout>');
42+
$upload_dir = project_config_val('upload_dir');
43+
$uldl_dir_fanout = project_config_val('uldl_dir_fanout');
4544
}
4645
return dir_hier_path($filename, $upload_dir, $uldl_dir_fanout);
4746
}
@@ -124,9 +123,8 @@ function get_hier_info() {
124123
static $dl_dir = null;
125124
static $fanout = null;
126125
if (!$dl_dir) {
127-
$conf = get_config();
128-
$dl_dir = parse_config($conf, "<download_dir>");
129-
$fanout = parse_config($conf, "<uldl_dir_fanout>");
126+
$dl_dir = project_config_val("download_dir");
127+
$fanout = project_config_val("uldl_dir_fanout");
130128
}
131129
return [$dl_dir, $fanout];
132130
}

html/inc/forum.inc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,12 @@ function show_post(
543543
return;
544544
}
545545

546-
$config = get_config();
547546
BoincForumPrefs::lookup($user);
548547
if (is_banished($user) && !is_moderator($logged_in_user, $forum)) {
549548
return;
550549
}
551550

552-
$no_forum_rating = parse_bool($config, "no_forum_rating");
551+
$no_forum_rating = project_config_bool("no_forum_rating");
553552

554553
$tokens = "";
555554
$options = get_output_options($logged_in_user);
@@ -694,7 +693,7 @@ function show_post(
694693
show_button_small("forum_edit.php?id=".$post->id."$tokens", tra("Edit"), tra("Edit this message"));
695694
}
696695
if (is_moderator($logged_in_user, $forum)) {
697-
show_post_moderation_links($config, $logged_in_user, $post, $forum, $tokens);
696+
show_post_moderation_links($logged_in_user, $post, $forum, $tokens);
698697
}
699698
if ($post->modified) {
700699
echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified));
@@ -784,7 +783,6 @@ function show_post_and_context($post, $thread, $forum, $options, $n) {
784783
return;
785784
}
786785

787-
$config = get_config();
788786
$title = cleanup_title($thread->title);
789787
if ($post->hidden) {
790788
$deleted = "<br><font color=red>[".tra("Hidden by a moderator")."]</font>";
@@ -1222,10 +1220,10 @@ function get_thread_posts($threadid, $sort_style, $show_hidden) {
12221220
// logged in user has moderation rights.
12231221
//
12241222
function show_post_moderation_links(
1225-
$config, $logged_in_user, $post, $forum, $tokens
1223+
$logged_in_user, $post, $forum, $tokens
12261224
){
1227-
$moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban");
1228-
$moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban");
1225+
$moderators_allowed_to_ban = project_config_bool("moderators_allowed_to_ban");
1226+
$moderators_vote_to_ban = project_config_bool("moderators_vote_to_ban");
12291227

12301228
if ($post->hidden) {
12311229
show_button_small("forum_moderate_post_action.php?action=unhide&amp;id=".$post->id."$tokens", tra("Unhide"), tra("Unhide this post"));
@@ -1458,7 +1456,7 @@ function is_subscribed($id, $subs) {
14581456
//
14591457
function is_forum_visible_to_user($forum, $user) {
14601458
if ($forum->parent_type == 1) {
1461-
if (parse_config(get_config(), "<team_forums_members_only>")) {
1459+
if (project_config_val("team_forums_members_only")) {
14621460
if (!$user) return false;
14631461
if ($user->teamid != $forum->category) return false;
14641462
}

0 commit comments

Comments
 (0)