From 0cdee0af4ea4f46c7d09b01e3551ea1e948e5fb1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 7 Mar 2014 00:37:44 -0800 Subject: [PATCH] Fixes for the BOINC-wide teams site - the exported team list wasn't parsing due to non-ASCII characters in some team descriptions. htmlspecialchars() wasn't doing the job. Use DOMDocument instead. - If SHOW_NONVALIDATE_TEAMS is set (as on the BOINC-wide teams site) show teams whose founders email addresses are not validated (and hence won't be exported). --- html/inc/team.inc | 4 ++++ html/ops/team_export.php | 13 ++++++++++++- html/user/team_search.php | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/html/inc/team.inc b/html/inc/team.inc index 60f1507a86..9ffa2df56d 100644 --- a/html/inc/team.inc +++ b/html/inc/team.inc @@ -88,6 +88,10 @@ function display_team_page($team, $user) { if (strlen($team->description)) { row2(tra('Description'), sanitize_html($team->description)); } + row2("Created", date_str($team->create_time)); + if (defined("SHOW_NONVALIDATED_TEAMS")) { + row2("Founder email validated", $user->email_validated?"Yes":"No (team will not be exported)"); + } if (strlen($team->url)) {; if (strstr($team->url, "http://")) { $x = $team->url; diff --git a/html/ops/team_export.php b/html/ops/team_export.php index 2510b8df07..8b79af26a4 100755 --- a/html/ops/team_export.php +++ b/html/ops/team_export.php @@ -45,10 +45,21 @@ function escape2($strin) { } function escape($strin) { - return htmlspecialchars($strin); + $dom = new DOMDocument('1.0'); + $element = $dom->createElement('Element'); + $element->appendChild( + $dom->createTextNode($strin) + ); + + $dom->appendChild($element); + $x = $dom->saveXml(); + $x = substr($x, 31); + $x = substr($x, 0, -11); + return $x; } function handle_team($team, $f) { + echo "Team: $team->name\n"; $user = BoincUser::lookup_id($team->userid); if (!$user) { echo "no user for team $team->id\n"; diff --git a/html/user/team_search.php b/html/user/team_search.php index 91aa5b0d2a..e46bae61b9 100644 --- a/html/user/team_search.php +++ b/html/user/team_search.php @@ -66,6 +66,11 @@ function show_list($list) { echo " ".tra("Team name")." + "; + if (defined("SHOW_NONVALIDATED_TEAMS")) { + echo "Validated?\n"; + } + echo " ".tra("Description")." ".tra("Average credit")." ".tra("Type")." @@ -78,6 +83,14 @@ function show_list($list) { $j = $i++ % 2; echo " id>$team->name + "; + if (defined("SHOW_NONVALIDATED_TEAMS")) { + $user = BoincUser::lookup_id($team->userid); + echo ""; + echo $user->email_validated?"Yes":"No"; + echo "\n"; + } + echo " ".sanitize_html($team->description)." ".format_credit($team->expavg_credit)." $type