mirror of https://github.com/BOINC/boinc.git
- admin web: fix profile screen form formatting
- web: remove get_transform_settings_from_user(). There's only get_output_options() NOTE: why is text_transform() doing stripslashes()? The slashes shouldn't be in the DB in the first place. There's some fundamental confusion here. - web: fix uotd.php svn path=/trunk/boinc/; revision=14866
This commit is contained in:
parent
926659e750
commit
0dadf8d62f
|
@ -2019,4 +2019,24 @@ Rom 6 Mar 2008
|
|||
|
||||
lib/
|
||||
win_util.C
|
||||
|
||||
|
||||
David 6 Mar 2008
|
||||
- admin web: fix profile screen form formatting
|
||||
- web: remove get_transform_settings_from_user().
|
||||
There's only get_output_options()
|
||||
|
||||
NOTE: why is text_transform() doing stripslashes()?
|
||||
The slashes shouldn't be in the DB in the first place.
|
||||
There's some fundamental confusion here.
|
||||
|
||||
- web: fix uotd.php
|
||||
|
||||
html/
|
||||
inc/
|
||||
forum.inc
|
||||
profile.inc
|
||||
text_transform.inc
|
||||
ops/
|
||||
profile_screen_form.php
|
||||
user/
|
||||
uotd.php
|
||||
|
|
|
@ -426,14 +426,6 @@ function is_ignoring($user, $other_user) {
|
|||
return in_array($other_user->id, $list);
|
||||
}
|
||||
|
||||
function get_output_options($user) {
|
||||
if (!$user) return null;
|
||||
$options = new output_options();
|
||||
if ($user->prefs->images_as_links) $options->images_as_links = 1;
|
||||
if ($user->prefs->link_popup) $options->link_popup = 1;
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Display an individual post
|
||||
//
|
||||
function show_post(
|
||||
|
|
|
@ -170,7 +170,8 @@ function get_profile_summary($profile) {
|
|||
// Displays a user's profile (if they have one);
|
||||
// $screen_mode is set if we're in the administrative profile-screening page,
|
||||
// in which case we show everything
|
||||
|
||||
// This assumes we're inside a table; it generates table rows
|
||||
//
|
||||
function show_profile($user, $logged_in_user, $screen_mode = false) {
|
||||
BoincForumPrefs::lookup($user);
|
||||
if (is_banished($user)) {
|
||||
|
@ -186,7 +187,7 @@ function show_profile($user, $logged_in_user, $screen_mode = false) {
|
|||
if ($can_edit) {
|
||||
row1("<a href=create_profile.php>Edit your profile</a>");
|
||||
}
|
||||
|
||||
|
||||
// If screening is enabled, only show picture in certain situations
|
||||
//
|
||||
$show_picture = $profile->has_picture;
|
||||
|
@ -213,12 +214,9 @@ function show_profile($user, $logged_in_user, $screen_mode = false) {
|
|||
|
||||
// Setup text output options based on logged in user forum settings
|
||||
//
|
||||
if (!$screen_mode) {
|
||||
$logged_in_user = get_logged_in_user(false);
|
||||
BoincForumPrefs::lookup($logged_in_user);
|
||||
$options = get_transform_settings_from_user($logged_in_user);
|
||||
}
|
||||
|
||||
BoincForumPrefs::lookup($logged_in_user);
|
||||
$options = get_output_options($logged_in_user);
|
||||
|
||||
row1(show_profile_heading1());
|
||||
row1(output_transform($profile->response1,$options), 2, "foobar");
|
||||
row1(show_profile_heading2());
|
||||
|
|
|
@ -7,98 +7,89 @@ require_once('../inc/sanitize_html.inc');
|
|||
// and other such niceties.
|
||||
|
||||
class output_options {
|
||||
var $bb2html; // BBCode as HTML? (on)
|
||||
var $images_as_links; // Images as hyperlinks? (off)
|
||||
var $link_popup; // Links in new windows? (off)
|
||||
var $closeTags; // Close extra HTML tags? (on)
|
||||
var $nl2br; // Convert newlines to <br>'s? (on)
|
||||
var $htmlitems; // Convert special chars to HTML entities? (on)
|
||||
var $htmlscrub; // Scrub "bad" HTML tags? (off)
|
||||
var $stripslashes; // Strip slashes (depends)
|
||||
var $highlight_terms;// Array of terms to be highlighted (off)
|
||||
var $bb2html; // BBCode as HTML? (on)
|
||||
var $images_as_links; // Images as hyperlinks? (off)
|
||||
var $link_popup; // Links in new windows? (off)
|
||||
var $closeTags; // Close extra HTML tags? (on)
|
||||
var $nl2br; // Convert newlines to <br>'s? (on)
|
||||
var $htmlitems; // Convert special chars to HTML entities? (on)
|
||||
var $htmlscrub; // Scrub "bad" HTML tags? (off)
|
||||
var $stripslashes; // Strip slashes (depends)
|
||||
var $highlight_terms;// Array of terms to be highlighted (off)
|
||||
|
||||
// Constructor - set the defaults.
|
||||
|
||||
function output_options() {
|
||||
$this->bb2html = 1;
|
||||
$this->images_as_links = 0;
|
||||
$this->link_popup = 0;
|
||||
$this->closeTags = 1;
|
||||
$this->nl2br = 1;
|
||||
$this->htmlitems = 1;
|
||||
$this->htmlscrub = 0;
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$this->stripslashes = 1;
|
||||
}
|
||||
$this->highlight_terms = 0;
|
||||
return true;
|
||||
}
|
||||
function output_options() {
|
||||
$this->bb2html = 1;
|
||||
$this->images_as_links = 0;
|
||||
$this->link_popup = 0;
|
||||
$this->closeTags = 1;
|
||||
$this->nl2br = 1;
|
||||
$this->htmlitems = 1;
|
||||
$this->htmlscrub = 0;
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$this->stripslashes = 1;
|
||||
}
|
||||
$this->highlight_terms = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Define the terms to be highlighted (for use with searches and such)
|
||||
|
||||
function setHighlightTerms($terms) {
|
||||
if (is_array($terms)) {
|
||||
$this->highlight_terms = $terms;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function setHighlightTerms($terms) {
|
||||
if (is_array($terms)) {
|
||||
$this->highlight_terms = $terms;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual transformation of the text.
|
||||
// TODO: Make this part of the above class.
|
||||
|
||||
function output_transform($text, $options = NULL) {
|
||||
// Options is a output_options object, defined above
|
||||
if (!$options) {
|
||||
$options = new output_options; // Defaults in the class definition
|
||||
}
|
||||
|
||||
if ($options->stripslashes) {
|
||||
$text = stripslashes($text);
|
||||
}
|
||||
if ($options->htmlitems) {
|
||||
//$text = htmlentities($text);
|
||||
$text = htmlspecialchars($text);
|
||||
}
|
||||
// if ($options->htmlscrub) {
|
||||
// $text = sanitize_html($text);
|
||||
// }
|
||||
if ($options->nl2br) {
|
||||
$text = nl2br($text);
|
||||
}
|
||||
if ($options->bb2html) {
|
||||
$text = bb2html($text);
|
||||
}
|
||||
if ($options->images_as_links) {
|
||||
$text = image_as_link($text);
|
||||
}
|
||||
if ($options->link_popup) {
|
||||
$text = externalize_links($text);
|
||||
}
|
||||
if (is_array($options->highlight_terms)) {
|
||||
$text = highlight_terms($text, $options->highlight_terms);
|
||||
}
|
||||
return $text;
|
||||
// Options is a output_options object, defined above
|
||||
if (!$options) {
|
||||
$options = new output_options; // Defaults in the class definition
|
||||
}
|
||||
|
||||
if ($options->stripslashes) {
|
||||
$text = stripslashes($text);
|
||||
}
|
||||
if ($options->htmlitems) {
|
||||
//$text = htmlentities($text);
|
||||
$text = htmlspecialchars($text);
|
||||
}
|
||||
// if ($options->htmlscrub) {
|
||||
// $text = sanitize_html($text);
|
||||
// }
|
||||
if ($options->nl2br) {
|
||||
$text = nl2br($text);
|
||||
}
|
||||
if ($options->bb2html) {
|
||||
$text = bb2html($text);
|
||||
}
|
||||
if ($options->images_as_links) {
|
||||
$text = image_as_link($text);
|
||||
}
|
||||
if ($options->link_popup) {
|
||||
$text = externalize_links($text);
|
||||
}
|
||||
if (is_array($options->highlight_terms)) {
|
||||
$text = highlight_terms($text, $options->highlight_terms);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
// Take a user object and get their settings to create an output_options
|
||||
// object from them.
|
||||
|
||||
function get_transform_settings_from_user($user, $options = '') {
|
||||
// $user - a user object
|
||||
// $options - a output_options object (optional)
|
||||
if (!$options) {
|
||||
$options = new output_options; // Give defaults
|
||||
}
|
||||
if ($user->images_as_links==1){
|
||||
$options->images_as_links = 1;
|
||||
}
|
||||
if ($user->link_popup==1){
|
||||
$options->link_popup = 1;
|
||||
}
|
||||
return $options;
|
||||
function get_output_options($user) {
|
||||
$options = new output_options();
|
||||
if ($user) {
|
||||
if ($user->prefs->images_as_links) $options->images_as_links = 1;
|
||||
if ($user->prefs->link_popup) $options->link_popup = 1;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Converts bbcode to proper HTML
|
||||
|
@ -132,7 +123,7 @@ function bb2html($text) {
|
|||
"@\[trac\](?:\#|ticket:)(\d+)\[/trac\]@is",
|
||||
"@\[trac\]wiki:(.*?)\[/trac\]@is",
|
||||
"@\[trac\]changeset:(\d+)\[/trac\]@is"
|
||||
//Note: The above list array member ensures we're within a list
|
||||
//Note: The above list array member ensures we're within a list
|
||||
//when doing list item transformations.
|
||||
//TODO: Make sure we're not between two lists
|
||||
);
|
||||
|
@ -195,7 +186,7 @@ function externalize_links($text) {
|
|||
// Converts image tags to links to the images.
|
||||
|
||||
function image_as_link($text){
|
||||
/* This function depends on sanitized HTML */
|
||||
/* This function depends on sanitized HTML */
|
||||
// Build some regex (should be a *lot* faster)
|
||||
$pattern = '@<img src=([^>]+)>@si'; // Gives us the URL in ${1}...
|
||||
$replacement = '<a href=${1}>[Image Link]</a>'; // Turns that URL into a hyperlink
|
||||
|
@ -206,50 +197,50 @@ function image_as_link($text){
|
|||
// Closes open HTML tags. Not quite perfect...
|
||||
|
||||
function closeTags($str = null) {
|
||||
// Function from http://episteme.arstechnica.com/eve/ubb.x/a/tpc/f/6330927813/m/139006252731/r/287008552731#287008552731
|
||||
// (thanks Ageless for finding it)
|
||||
// Edited by Rob to better fit in with boinc's needs
|
||||
|
||||
// List of tags to check $str for
|
||||
// TODO: Adapt to use the pre-existing array of tags above
|
||||
$tags = array('b', 'i', 'a', 'p', 'font[^>]?', 'strong', 'ul', 'li', 'pre', 'blockquote', 'u');
|
||||
// Note on $tags - no br or img, as they have no closing tags - can we define this above?
|
||||
// Maybe define two arrays, those with closing tags and those without, and combine the
|
||||
// two of them for the standard HTML sanitizing function?
|
||||
// Function from http://episteme.arstechnica.com/eve/ubb.x/a/tpc/f/6330927813/m/139006252731/r/287008552731#287008552731
|
||||
// (thanks Ageless for finding it)
|
||||
// Edited by Rob to better fit in with boinc's needs
|
||||
|
||||
// List of tags to check $str for
|
||||
// TODO: Adapt to use the pre-existing array of tags above
|
||||
$tags = array('b', 'i', 'a', 'p', 'font[^>]?', 'strong', 'ul', 'li', 'pre', 'blockquote', 'u');
|
||||
// Note on $tags - no br or img, as they have no closing tags - can we define this above?
|
||||
// Maybe define two arrays, those with closing tags and those without, and combine the
|
||||
// two of them for the standard HTML sanitizing function?
|
||||
|
||||
// Don't do anything if the string is too short
|
||||
if (strlen($str) < 3) {
|
||||
return $str;
|
||||
} else {
|
||||
// Loop over $str and count the opening and closing for each tag in $tags
|
||||
foreach ($tags as $tag) {
|
||||
$m = array();
|
||||
$o = preg_match_all("/<(".$tag.")>/", $str, $m);
|
||||
$c = substr_count($str, "</{$tag}>");
|
||||
// Don't do anything if the string is too short
|
||||
if (strlen($str) < 3) {
|
||||
return $str;
|
||||
} else {
|
||||
// Loop over $str and count the opening and closing for each tag in $tags
|
||||
foreach ($tags as $tag) {
|
||||
$m = array();
|
||||
$o = preg_match_all("/<(".$tag.")>/", $str, $m);
|
||||
$c = substr_count($str, "</{$tag}>");
|
||||
|
||||
$open[$tag] = ($o < $c) ? $c - $o : 0;
|
||||
$close[$tag] = ($c < $o) ? $o - $c : 0;
|
||||
$open[$tag] = ($o < $c) ? $c - $o : 0;
|
||||
$close[$tag] = ($c < $o) ? $o - $c : 0;
|
||||
|
||||
// Debuggin'
|
||||
//echo "<pre>Tag: {$tag}\nOpen: {$o}\nClose: {$c}\nOT: {$open[$tag]}\nCT: {$close[$tag]}</pre><hr />";
|
||||
}
|
||||
// Debuggin'
|
||||
//echo "<pre>Tag: {$tag}\nOpen: {$o}\nClose: {$c}\nOT: {$open[$tag]}\nCT: {$close[$tag]}</pre><hr />";
|
||||
}
|
||||
|
||||
// Prepend the return string with an opening tag as needed
|
||||
/* $pre = ''; ...uhh... doesn't work right
|
||||
// Prepend the return string with an opening tag as needed
|
||||
/* $pre = ''; ...uhh... doesn't work right
|
||||
|
||||
foreach ($open as $tag => $cnt) {
|
||||
$pre .= ($cnt > 0) ? "<{$tag}>" : '';
|
||||
} */
|
||||
foreach ($open as $tag => $cnt) {
|
||||
$pre .= ($cnt > 0) ? "<{$tag}>" : '';
|
||||
} */
|
||||
|
||||
// Append the return string with a closing tag as needed
|
||||
$post = '';
|
||||
// Append the return string with a closing tag as needed
|
||||
$post = '';
|
||||
|
||||
foreach ($close as $tag => $cnt) {
|
||||
$post .= ($cnt > 0) ? "</{$tag}>" : '';
|
||||
}
|
||||
foreach ($close as $tag => $cnt) {
|
||||
$post .= ($cnt > 0) ? "</{$tag}>" : '';
|
||||
}
|
||||
|
||||
return /*$pre.*/$str.$post;
|
||||
}
|
||||
return /*$pre.*/$str.$post;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,30 +34,31 @@ if (function_exists('profile_screen_query')) {
|
|||
." and verification=0 "
|
||||
." and uotd_time is null "
|
||||
." and expavg_credit>1 "
|
||||
." and (response1 <> '' or response2 <> '') "
|
||||
." order by recommend desc limit 20"
|
||||
;
|
||||
}
|
||||
$result = mysql_query($query);
|
||||
|
||||
$n = 0;
|
||||
echo "<form method=\"get\" action=\"profile_screen_action.php\">\n";
|
||||
echo "<form action=profile_screen_action.php>
|
||||
";
|
||||
start_table();
|
||||
$found = false;
|
||||
while ($profile = mysql_fetch_object($result)) {
|
||||
$found = true;
|
||||
echo "<tr><td>
|
||||
";
|
||||
echo "<tr><td valign=top>";
|
||||
buttons($n);
|
||||
echo "
|
||||
</td><td>
|
||||
";
|
||||
echo "recommends: $profile->recommend
|
||||
<br>rejects: $profile->reject
|
||||
<br>Name: $profile->name
|
||||
<br>recommends: $profile->recommend
|
||||
<br>rejects: $profile->reject
|
||||
<br>RAC: $profile->expavg_credit
|
||||
<br>
|
||||
";
|
||||
echo "</td><td><table border=2> ";
|
||||
show_profile($profile, $logged_in_user, true);
|
||||
echo "<hr></td></tr>\n";
|
||||
echo "</table></td></tr>\n";
|
||||
echo "<input type=\"hidden\" name=\"userid$n\" value=\"$profile->userid\">\n";
|
||||
$n++;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ if (!$profile) {
|
|||
$d = date("d F Y", time());
|
||||
$user = lookup_user_id($profile->userid);
|
||||
page_head("User of the Day for $d: $user->name");
|
||||
show_profile($profile->userid);
|
||||
start_table();
|
||||
show_profile($user, get_logged_in_user(false));
|
||||
end_table();
|
||||
}
|
||||
|
||||
page_tail();
|
||||
|
|
Loading…
Reference in New Issue