- web: some fixes that arose from converting BOINC's news

to forum format.


svn path=/trunk/boinc/; revision=19963
This commit is contained in:
David Anderson 2009-12-18 04:32:30 +00:00
parent b762fab7da
commit e57f286e47
14 changed files with 65 additions and 86 deletions

View File

@ -10254,3 +10254,17 @@ Rom 17 Dec 2009
clientgui/
Events.h
David 17 Dec 2009
- web: some fixes that arose from converting BOINC's news
to forum format.
html/
inc/
text_transform.inc
forum.inc
news.inc
ops/
news_convert.php
user/
forum_forum.php

View File

@ -54,7 +54,7 @@ if ($platform == 'win') {
} else if ($platform == 'web') {
$x = $web;
} else {
error_page('bad name');
boinc_error_page('bad name');
}
$found = false;
@ -66,7 +66,7 @@ foreach ($x as $y) {
}
}
if (!$found) {
error_page('bad item');
boinc_error_page('bad item');
}
?>

View File

@ -1,4 +1,4 @@
<?
<?php
$project_news = array(
array("November 27, 2009",

View File

@ -1,5 +1,7 @@
<?php
require_once("../inc/util_basic.inc");
if (0) {
$x = $_SERVER['PHP_SELF'];
$path = "/tmp/php_pids/".getmypid();
@ -125,14 +127,6 @@ function html_text($x) {
";
}
function start_table($extra="width=\"100%\"") {
echo "<table class=bordered $extra>";
}
function end_table() {
echo "</table>\n";
}
function list_start($attrs = 'width="100%"') {
echo "<p><table $attrs border=0 cellpadding=6>\n";
}
@ -195,7 +189,7 @@ function list_end() {
echo "</table><p>\n";
}
function error_page($x) {
function boinc_error_page($x) {
page_head("Error");
echo $x;
page_tail();
@ -214,31 +208,8 @@ function block_end() {
";
}
function get_str($name) {
if (isset($_GET[$name])) {
$x = $_GET[$name];
$x = trim($x);
return mysql_real_escape_string($x);
}
return null;
}
function show_link($url) {
echo "<br><a href=$url>$url</a>";
}
function parse_element($xml, $tag) {
$element = null;
$closetag = "</" . substr($tag,1);
$x = strstr($xml, $tag);
if ($x) {
if (strstr($tag, "/>")) return $tag;
$y = substr($x, strlen($tag));
$n = strpos($y, $closetag);
if ($n) {
$element = substr($y, 0, $n);
}
}
return trim($element);
}
?>

View File

@ -146,7 +146,7 @@ function show_platform_xml($short_name, $p, $dev) {
if ($pname && $version) {
$p = $platforms[$pname];
if (!$p) {
error_page("platform not found");
boinc_error_page("platform not found");
}
$long_name = $p["name"];
$va = $p["versions"];
@ -158,7 +158,7 @@ if ($pname && $version) {
exit();
}
}
error_page( "version not found\n");
boinc_error_page( "version not found\n");
}
if ($xml) {

View File

@ -118,16 +118,16 @@ if ($send_email) {
$subject = stripslashes($_GET['subject']);
$vol = vol_lookup($volid);
if (!$vol || $vol->hide) {
error_page("No such volunteer $volid");
boinc_error_page("No such volunteer $volid");
}
$msg = stripslashes($_GET['message']);
if (!$msg) {
error_page("You must supply a message");
boinc_error_page("You must supply a message");
}
$body = "The following message was sent by a BOINC Help user.\n";
$email_addr = $_GET['email_addr'];
if (!is_valid_email_addr($email_addr)) {
error_page("You must specify a valid email address");
boinc_error_page("You must specify a valid email address");
}
$reply = "\r\nreply-to: $email_addr";
$body .= "\n\n";
@ -141,15 +141,15 @@ if ($send_email) {
$volid = $_GET['volid'];
$vol = vol_lookup($volid);
if (!$vol) {
error_page("No such volunteer $volid");
boinc_error_page("No such volunteer $volid");
}
$x = $_GET['rating'];
if ($x==null) {
error_page("no rating given");
boinc_error_page("no rating given");
}
$rating = (int) $x;
if ($rating < 0 || $rating > 5) {
error_page("bad rating");
boinc_error_page("bad rating");
}
$comment = stripslashes($_GET['comment']);
$r = null;
@ -173,7 +173,7 @@ if ($send_email) {
}
if (!$retval) {
echo mysql_error();
error_page("database error");
boinc_error_page("database error");
}
page_head("Feedback recorded");
echo "Your feedback has been recorded. Thanks.

View File

@ -79,27 +79,27 @@ function print_form($vol, $action_name) {
function get_form_data() {
$vol->name = stripslashes($_GET['volname']);
if (!$vol->name) error_page("Name must not be blank");
if (strstr($vol->name, "<")) error_page("No &lt; allowed");
if (!$vol->name) boinc_error_page("Name must not be blank");
if (strstr($vol->name, "<")) boinc_error_page("No &lt; allowed");
$vol->password = stripslashes($_GET['password']);
if (!$vol->password) error_page("Password must not be blank");
if (!$vol->password) boinc_error_page("Password must not be blank");
$vol->email_addr = stripslashes($_GET['email_addr']);
if (!$vol->email_addr) error_page("Email address must not be blank");
if (!$vol->email_addr) boinc_error_page("Email address must not be blank");
$vol->skypeid = stripslashes($_GET['skypeid']);
if (!$vol->skypeid) error_page("Skype ID must not be blank");
if (!$vol->skypeid) boinc_error_page("Skype ID must not be blank");
$vol->lang1 = stripslashes($_GET['lang1']);
if (!$vol->lang1) error_page("Primary language must not be blank");
if (!is_spoken_language($vol->lang1)) error_page("Not a language");
if (!$vol->lang1) boinc_error_page("Primary language must not be blank");
if (!is_spoken_language($vol->lang1)) boinc_error_page("Not a language");
$vol->lang2 = stripslashes($_GET['lang2']);
if (!is_spoken_language($vol->lang2)) error_page("Not a language");
if (!is_spoken_language($vol->lang2)) boinc_error_page("Not a language");
$vol->country = stripslashes($_GET['country']);
if (!is_valid_country($vol->country)) error_page("Bad country");
if (!is_valid_country($vol->country)) boinc_error_page("Bad country");
$vol->specialties = stripslashes($_GET['specialties']);
if (strstr($vol->specialties, "<")) error_page("No &lt; allowed");
if (strstr($vol->specialties, "<")) boinc_error_page("No &lt; allowed");
$vol->projects = stripslashes($_GET['projects']);
if (strstr($vol->projects, "<")) error_page("No &lt; allowed");
if (strstr($vol->projects, "<")) boinc_error_page("No &lt; allowed");
$vol->availability = stripslashes($_GET['availability']);
if (strstr($vol->availability, "<")) error_page("No &lt; allowed");
if (strstr($vol->availability, "<")) boinc_error_page("No &lt; allowed");
$vol->voice_ok = $_GET['voice_ok']?1:0;
$vol->text_ok = $_GET['text_ok']?1:0;
$vol->hide = $_GET['hide']?1:0;
@ -125,11 +125,11 @@ if ($create == 'OK') {
$vol2 = vol_lookup_name($vol->name);
if ($vol2) {
error_page("That name is already taken");
boinc_error_page("That name is already taken");
}
$vol2 = vol_lookup_email($vol->email_addr);
if ($vol2) {
error_page("There's already an account with email address $vol->email_addr");
boinc_error_page("There's already an account with email address $vol->email_addr");
}
$retval = vol_insert($vol);
if (!$retval) {
@ -168,14 +168,14 @@ if ($create == 'OK') {
$password = stripslashes($_GET['password']);
$vol = vol_lookup_email($email_addr);
if (!$vol) {
error_page("Bad email address $email_addr");
boinc_error_page("Bad email address $email_addr");
}
if (!$password) {
email_password($vol);
exit();
}
if ($password != $vol->password) {
error_page("Bad password");
boinc_error_page("Bad password");
}
page_head("Edit your Help Volunteer Account");
echo "
@ -191,10 +191,10 @@ if ($create == 'OK') {
$old_password = stripslashes($_GET['old_password']);
$vol = vol_lookup_email($old_email_addr);
if (!$vol) {
error_page("Bad email address $old_email_addr");
boinc_error_page("Bad email address $old_email_addr");
}
if ($old_password != $vol->password) {
error_page("Bad password");
boinc_error_page("Bad password");
}
$vol2 = get_form_data();
$vol2->timezone = $vol->timezone;

View File

@ -57,8 +57,8 @@ function show_totals() {
}
function show_news_items() {
require_once("boinc_news.php");
require_once("../html/inc/news.inc");
require_once("../html/inc/forum.inc");
echo "
<table border=0 cellpadding=8>
<tr><td class=heading_right>
@ -66,15 +66,8 @@ function show_news_items() {
<span class=section_title>".tra("News")."</span>
</center>
";
$nnews_items = 6;
show_news($project_news, $nnews_items);
if (count($project_news) > $nnews_items) {
echo "<a href=old_news.php>".tra("... more")."</a>\n";
}
echo "<p><font size=-2>";
printf(tra('News is available as an %sRSS feed%s'), '<a href="rss_main.php">', '</a>');
echo "<img src=xml.gif alt=\"RSS logo\"></font>
show_news(0, 5);
echo "
</td></tr></table>
";
}

View File

@ -4,7 +4,7 @@ require_once("poll.inc");
require_once("../html/inc/translation.inc");
require_once("poll_data.inc");
error_page("The poll is closed");
boinc_error_page("The poll is closed");
function error() {
page_head(tra("Error - results not recorded"));
echo tra("An internal error has prevented us from recording your survey response. Please try again later.");

View File

@ -285,7 +285,7 @@ function thread_is_unread($user, $thread) {
//
function cleanup_title($title) {
$x = strip_tags(bb2html($title));
$x = trim(htmlspecialchars($x));
$x = trim($x);
if (strlen($x)==0) return "(no title)";
else return $x;
}

View File

@ -69,7 +69,7 @@ function show_news($start, $count) {
}
if ($count) {
echo "<br><br><a href=\"old_news.php\">...more</a>";
echo "<br><br><a href=".URL_BASE."old_news.php>...more</a>";
}
echo "
<br><br><p class=\"smalltext\">

View File

@ -41,7 +41,7 @@ class output_options {
$this->images_as_links = 0;
$this->link_popup = 0;
$this->nl2br = 1;
$this->htmlitems = 1;
$this->htmlitems = 0;
$this->htmlscrub = 0;
$this->highlight_terms = 0;
return true;
@ -114,12 +114,12 @@ function bb2html($text, $export=false) {
"@\[b\](.*?)\[/b\]@is",
"@\[i\](.*?)\[/i\]@is",
"@\[u\](.*?)\[/u\]@is",
"@\[url=$httpsregex\](.*?)\[/url\]@i",
"@\[url\]$httpsregex\[/url\]@i",
"@\[link=$urlregex\](.*?)\[/link\]@i",
"@\[link\]$urlregex\[/link\]@i",
"@\[url=$urlregex\](.*?)\[/url\]@i",
"@\[url\]$urlregex\[/url\]@i",
"@\[url=$httpsregex\](.*?)\[/url\]@is",
"@\[url\]$httpsregex\[/url\]@is",
"@\[link=$urlregex\](.*?)\[/link\]@is",
"@\[link\]$urlregex\[/link\]@is",
"@\[url=$urlregex\](.*?)\[/url\]@is",
"@\[url\]$urlregex\[/url\]@is",
"@\[quote=(.*?)\](.*?)\[/quote\]@is",
"@\[quote\](.*?)\[/quote\]@is",
"@\[list\](.*?)\[/list\]@is",

View File

@ -86,8 +86,10 @@ foreach (array_reverse($project_news) as $item) {
}
$when = strtotime($item[0]);
$title = html_to_bbcode($title);
$title = str_replace("\n", " ", $title);
$title = mysql_real_escape_string($title);
$content = html_to_bbcode($content);
$content = str_replace("\n", " ", $content);
$content = mysql_real_escape_string($content);
$thread_id = BoincThread::insert("(forum, owner, title, create_time, timestamp, replies) values ($forum_id, $user->id, '$title', $when, $when, 0)");

View File

@ -193,12 +193,11 @@ function show_forum($forum, $start, $sort_style, $user) {
echo "</nobr></td>";
$titlelength = 48;
$title = strip_tags(bb2html($thread->title));
$title = cleanup_title($thread->title);
if (strlen($title) > $titlelength) {
$title = substr($title,0,$titlelength)."...";
$title = substr($title, 0, $titlelength)."...";
}
$title = cleanup_title($title);
echo '<td class="threadline"><a href="forum_thread.php?id='.$thread->id.'"><b>'.$title.'</b></a><br></td>';
echo "<td class=\"threadline\"><a href=\"forum_thread.php?id=$thread->id\"><b>$title</b></a><br></td>";
$n = ($n+1)%2;
echo '