mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4152
This commit is contained in:
parent
af533fb922
commit
2634204c88
|
@ -16973,3 +16973,65 @@ David 3 Sept 2004
|
|||
app_start.C
|
||||
client_types.C,h
|
||||
cs_apps.C
|
||||
|
||||
David 4 Sept 2004
|
||||
- New features for message boards (from Janus Kristensen):
|
||||
Added:
|
||||
- External avatars (but commented it out -
|
||||
it's better to use hosted avatars)
|
||||
(Tiny images under people's name)
|
||||
- Hosted avatars
|
||||
(Uploads and scales to 100x100 in the IMGAGE_PATH dir)
|
||||
- Special users
|
||||
(Project admins, devs, newcomers etc. will get a line
|
||||
telling what they are under their name)
|
||||
- Option to display images as links
|
||||
- Option to open links in a new window
|
||||
- Option to hide avatars
|
||||
- Option to enable/disable attach of signature by default
|
||||
- Settings for sorting is now handled using the database
|
||||
instead of cookies (ie. you can change host without
|
||||
having to set your preferences up again,
|
||||
some users also have cookies disabled)
|
||||
- Preview of signature
|
||||
- Unread posts are marked as "Unread"
|
||||
(if they are newer than 2 days (configurable in forum.inc)
|
||||
and user hasn't visited the post)
|
||||
- Interface to forum preferences and sorting methods
|
||||
- Link to interface from user preferences
|
||||
- Reset forum preferences button
|
||||
(Some users have reported that an unusually long
|
||||
signature with html could make the page unviewable. This fixes it)
|
||||
- Option to sort with "Oldest first" in answers in the FAQ area
|
||||
|
||||
Moved:
|
||||
- Signature input in user prefs to forum prefs
|
||||
|
||||
Fixed:
|
||||
- Sorting in answers in the FAQ area didn't work
|
||||
- minor speedups and html stuff
|
||||
|
||||
DB-stuff:
|
||||
- create forum_preferences & forum_logging
|
||||
- transfer old settings
|
||||
|
||||
NOTE: If you want to use these features, you will need to
|
||||
create two new DB tables (forum_preferences and forum_logging;
|
||||
just execute the commands from schema.sql)
|
||||
and you'll probably want to copy existing signatures and nposts
|
||||
from the user table (see html/ops/db_update.php)
|
||||
|
||||
html/
|
||||
inc/
|
||||
forum.inc
|
||||
forum_show.inc
|
||||
user.inc
|
||||
user/
|
||||
edit_forum_preferences_action.php (new)
|
||||
edit_forum_preferences_form.php (new)
|
||||
edit_user_info_action.php
|
||||
edit_user_info_form.php
|
||||
forum_forum.php
|
||||
forum_post.php
|
||||
forum_reply.php
|
||||
forum_thread.php
|
||||
|
|
|
@ -363,3 +363,25 @@ create table subscriptions (
|
|||
userid integer not null,
|
||||
threadid integer not null
|
||||
) type=InnoDB;
|
||||
|
||||
create table forum_preferences (
|
||||
userid integer not null default 0,
|
||||
signature varchar(254) not null default '',
|
||||
posts integer not null default 0,
|
||||
avatar varchar(254) not null default '',
|
||||
avatar_type tinyint(4) not null default 0,
|
||||
hide_avatars tinyint(1) unsigned not null default 0,
|
||||
sorting varchar(100) not null default '',
|
||||
no_signature_by_default tinyint(1) unsigned not null default 0,
|
||||
images_as_links tinyint(1) unsigned not null default 0,
|
||||
link_popup tinyint(1) unsigned not null default 0,
|
||||
mark_as_read_timestamp integer not null default 0,
|
||||
primary key (userid)
|
||||
) type=MyISAM;
|
||||
|
||||
create table forum_logging (
|
||||
userid integer not null default 0,
|
||||
threadid integer not null default 0,
|
||||
timestamp integer not null default 0,
|
||||
primary key (userid,threadid)
|
||||
) TYPE=MyISAM;
|
||||
|
|
|
@ -4,6 +4,19 @@ require_once('../inc/db.inc');
|
|||
require_once('../inc/sanitize_html.inc');
|
||||
require_once('../inc/time.inc');
|
||||
|
||||
define('AVATAR_WIDTH', 100);
|
||||
define('AVATAR_HEIGHT',100);
|
||||
define('ST_ADMIN', 'Project administrator');
|
||||
define('ST_MODERATOR', 'Forum moderator');
|
||||
define('ST_DEV', 'Developer');
|
||||
define('ST_VOLDEV', 'Volunteer developer');
|
||||
define('ST_SCIENT', 'Project scientist');
|
||||
define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days
|
||||
define('ST_NEW', 'New member');
|
||||
|
||||
|
||||
define('FORUM_OPEN_LINK_IN_NEW_WINDOW',1);
|
||||
define('MAX_FORUM_LOGGING_TIME', 172800); //3600*24*2 - 2 days
|
||||
define('NO_CONTROLS', 0);
|
||||
define('FORUM_CONTROLS', 1);
|
||||
define('HELPDESK_CONTROLS', 2);
|
||||
|
@ -20,16 +33,17 @@ $forum_sort_styles['modified-old'] = "Least recent post first";
|
|||
$forum_sort_styles['views-most'] = "Most views first";
|
||||
$forum_sort_styles['replies-most'] = "Most posts first";
|
||||
|
||||
$thread_sort_styles['timestamp'] = "Newest first";
|
||||
$thread_sort_styles['timestamp_asc'] = "Oldest first";
|
||||
$thread_sort_styles['score'] = "Highest rated first";
|
||||
|
||||
$faq_sort_styles['create_time'] = "Most recent question first";
|
||||
$faq_sort_styles['timestamp'] = "Most recent answer first";
|
||||
$faq_sort_styles['activity'] = "Most frequently asked first";
|
||||
|
||||
$answer_sort_styles['score'] = "Highest score first";
|
||||
$answer_sort_styles['timestamp'] = "Most recent first";
|
||||
|
||||
$thread_sort_styles['timestamp'] = "Newest first";
|
||||
$thread_sort_styles['timestamp_asc'] = "Oldest first";
|
||||
$thread_sort_styles['score'] = "Highest rated first";
|
||||
$answer_sort_styles['timestamp_asc'] = "Oldest first";
|
||||
|
||||
$thread_filter_styles['2'] = "\"Very helpful\"";
|
||||
$thread_filter_styles['1'] = "At least \"helpful\"";
|
||||
|
@ -182,11 +196,89 @@ function getFirstPost($threadID) {
|
|||
}
|
||||
}
|
||||
|
||||
function getForumPreferences($user){
|
||||
$sql = "SELECT * FROM forum_preferences WHERE userid = '".$user->id."'";
|
||||
$result = mysql_query($sql);
|
||||
if (mysql_num_rows($result)>0) {
|
||||
$prefs=mysql_fetch_object($result);
|
||||
|
||||
//Todo - find out how to simply merge two objects instead of specifying all the fields manually here
|
||||
$user->avatar=$prefs->avatar;
|
||||
$user->hide_avatars=$prefs->hide_avatars;
|
||||
$user->sorting=$prefs->sorting;
|
||||
$user->images_as_links=$prefs->images_as_links;
|
||||
$user->signature=$prefs->signature;
|
||||
$user->posts=$prefs->posts;
|
||||
$user->avatar_type=$prefs->avatar_type;
|
||||
$user->no_signature_by_default=$prefs->no_signature_by_default;
|
||||
$user->link_popup=$prefs->link_popup;
|
||||
$user->mark_as_read_timestamp=$prefs->mark_as_read_timestamp;
|
||||
$user->forum_preferences=1;
|
||||
} else {
|
||||
mysql_query("insert into forum_preferences set userid='".$user->id."'");
|
||||
$user->forum_preferences=0;
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
function getSortStyle($user,$place){
|
||||
list($forum,$thread,$faq,$answer)=explode("|",$user->sorting);
|
||||
return $$place;
|
||||
}
|
||||
|
||||
function setSortStyle($user,$place,$new_style){
|
||||
list($forum,$thread,$faq,$answer)=explode("|",$user->forum_sorting);
|
||||
$$place=$new_style;
|
||||
$user->forum_sorting=implode("|",array($forum,$thread,$faq,$answer));
|
||||
$sql = "UPDATE forum_preferences SET sorting = '".$user->forum_sorting."' where userid = '".$user->id."'";
|
||||
mysql_query($sql);
|
||||
}
|
||||
|
||||
function getThreadLastVisited($user, $thread){
|
||||
$sql = "SELECT timestamp from forum_logging where userid='".$user->id."' and threadid='".$thread->id."'";
|
||||
$result = mysql_query($sql);
|
||||
if ($result) {
|
||||
$data=mysql_fetch_object($result);
|
||||
$user->thread_last_visited=$data->timestamp;
|
||||
} else {
|
||||
}
|
||||
$user->thread_last_visited= max(time()-MAX_FORUM_LOGGING_TIME,$user->thread_last_visited,$user->mark_as_read_timestamp);
|
||||
//echo $user->thread_last_visited." - ".time();
|
||||
return $user;
|
||||
}
|
||||
|
||||
function setThreadLastVisited($user, $thread, $timestamp=""){
|
||||
if ($timestamp==""){$timestamp=time();};
|
||||
$sql = "REPLACE DELAYED into forum_logging set userid='".$user->id."', threadid='".$thread->id."', timestamp='$timestamp'";
|
||||
mysql_query($sql);
|
||||
}
|
||||
|
||||
|
||||
function incThreadViews($threadID) {
|
||||
$sql = "UPDATE thread SET views = views + 1 WHERE id = " . $threadID . " LIMIT 1";
|
||||
mysql_query($sql);
|
||||
}
|
||||
|
||||
function cleanup_forum_log(){
|
||||
$sql = "SELECT timestamp FROM forum_logging where userid=0 and threadid=0";
|
||||
$result=mysql_query($sql);
|
||||
if (mysql_num_rows($result)>0) {
|
||||
$data=mysql_fetch_object($result);
|
||||
if ($data->timestamp<time()-MAX_FORUM_LOGGING_TIME){
|
||||
$sql = "DELETE FROM forum_logging where timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0";
|
||||
mysql_query($sql);
|
||||
echo mysql_error();
|
||||
$sql = "REPLACE INTO forum_logging set userid=0, threadid=0, timestamp='".time()."'";
|
||||
mysql_query($sql);
|
||||
}
|
||||
} else {
|
||||
//No cleanup timestamp found, make one:
|
||||
$sql = "INSERT INTO forum_logging set userid=0, threadid=0, timestamp=0";
|
||||
mysql_query($sql);
|
||||
echo mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
/* Forum modifying functions. */
|
||||
|
||||
function createThread($forumID, $ownerID, $title, $content) {
|
||||
|
@ -206,7 +298,7 @@ function createThread($forumID, $ownerID, $title, $content) {
|
|||
|
||||
$postID = addPost($threadID, $ownerID, NULL, $content);
|
||||
|
||||
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $ownerID . " LIMIT 1";
|
||||
$sql = "UPDATE forum_preferences SET posts = posts + 1 WHERE userid = " . $ownerID . " LIMIT 1";
|
||||
mysql_query($sql);
|
||||
|
||||
$sql = "UPDATE forum SET threads = threads + 1, posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $forumID . " LIMIT 1";
|
||||
|
@ -222,7 +314,7 @@ function replyToThread($threadID, $userID, $content, $parent_post=NULL) {
|
|||
|
||||
addPost($threadID, $userID, $parent_post, $content);
|
||||
|
||||
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $userID . " LIMIT 1";
|
||||
$sql = "UPDATE forum_preferences SET posts = posts + 1 WHERE userid = " . $userID . " LIMIT 1";
|
||||
mysql_query($sql);
|
||||
|
||||
$sql = "UPDATE thread SET replies = replies + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $threadID . " LIMIT 1";
|
||||
|
@ -280,6 +372,10 @@ function show_posts($thread, $sort_style, $filter, $show_controls=true, $do_colo
|
|||
}
|
||||
|
||||
$posts = getPosts($thread->id, -1, -1, $sort_style);
|
||||
$logged_in_user = getThreadLastVisited($logged_in_user,$thread);
|
||||
setThreadLastVisited($logged_in_user,$thread);
|
||||
|
||||
|
||||
$firstPost = getFirstPost($thread->id);
|
||||
|
||||
if ($is_helpdesk) {
|
||||
|
@ -302,22 +398,40 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
|
|||
global $post_ratings;
|
||||
|
||||
$user = lookup_user_id($post->user);
|
||||
$sql = "SELECT * FROM profile WHERE userid = " . $user->id;
|
||||
$result2 = mysql_query($sql);
|
||||
$user->has_profile = (mysql_num_rows($result2) > 0);
|
||||
|
||||
$user = getForumPreferences($user);
|
||||
$data = mysql_query("SELECT userid FROM profile WHERE userid = " . $user->id); //Lookup existance of profile for user
|
||||
$user->has_profile = (mysql_numrows($data) > 0); //and store this info in the user object
|
||||
$user->has_avatar = ($user->avatar != ""); //for later access
|
||||
|
||||
$can_edit = $logged_in_user && $user->id == $logged_in_user->id;
|
||||
|
||||
echo "
|
||||
<tr class=\"row$n\" valign=top>
|
||||
<tr class=\"row$n\" valign=\"top\">
|
||||
<td>
|
||||
<a name= $post->id ></a>
|
||||
<a name=\"$post->id\"></a>
|
||||
";
|
||||
|
||||
echo user_links($user, URL_BASE);
|
||||
|
||||
if ($user->rights) { //If this user is somehow special
|
||||
if ($user->rights==1) $fstatus=ST_ADMIN; //this is displayed in the forums
|
||||
if ($user->rights==2) $fstatus=ST_MODERATOR; //so that people know who they are
|
||||
if ($user->rights==3) $fstatus=ST_DEV; //talking to.
|
||||
if ($user->rights==4) $fstatus=ST_VOLDEV;
|
||||
if ($user->rights==5) $fstatus=ST_SCIENT;
|
||||
/*...*/
|
||||
} else {
|
||||
if ($user->create_time>time()-ST_NEW_TIME) $fstatus=ST_NEW;
|
||||
/*...*/
|
||||
}
|
||||
if ($fstatus) echo "<br><font size=\"-2\">$fstatus</font>";
|
||||
|
||||
echo "
|
||||
<p style=\"font-size:8pt\">";
|
||||
|
||||
if ($user->has_avatar and $logged_in_user->hide_avatars!=1) echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".$user->avatar."\" alt=\"Avatar\"><br>";
|
||||
|
||||
echo "
|
||||
<p style=\"font-size:8pt\">
|
||||
Joined: ", gmdate('M j, Y', $user->create_time), "<br>Posts: ", $user->posts, "
|
||||
</p>
|
||||
</td>
|
||||
|
@ -327,10 +441,17 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
|
|||
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
|
||||
echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">";
|
||||
}
|
||||
|
||||
echo "
|
||||
<table width=100% cellpadding=0 cellspacing=0 border=0 cellborder=0>
|
||||
<tr valign=top>
|
||||
<td align=left style=border:0px><font size=-2>
|
||||
<td align=left style=border:0px><font size=-2>";
|
||||
|
||||
if ($post->timestamp>$logged_in_user->thread_last_visited){
|
||||
echo "<a name=\"unread\"><img src=\"".NEW_IMAGE."\" alt=\"Unread post\" height=\"".NEW_IMAGE_HEIGHT."\"></a>";
|
||||
}
|
||||
|
||||
echo "
|
||||
Posted: ", pretty_time_str($post->timestamp);
|
||||
;
|
||||
|
||||
|
@ -364,7 +485,22 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
|
|||
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
|
||||
echo "</form>";
|
||||
}
|
||||
echo "<p>", nl2br(stripslashes($post->content)), "</p>";
|
||||
|
||||
$posttext=nl2br(stripslashes($post->content));
|
||||
//echo $logged_in_user->images_as_links;
|
||||
|
||||
if ($logged_in_user->images_as_links==1){
|
||||
$posttext=image_as_link($posttext);
|
||||
}
|
||||
//echo $logged_in_user->link_popup;
|
||||
if ($logged_in_user->link_popup==1){
|
||||
$posttext=externalize_links($posttext);
|
||||
}
|
||||
|
||||
echo "<p>", $posttext, "</p>";
|
||||
|
||||
|
||||
|
||||
echo "<table width=100% cellspacing=0 cellpadding=0>
|
||||
<tr valign=\"bottom\">
|
||||
<td align=\"left\" style=\"border:0px; font-size:7pt\"><i>ID: ", $post->id;
|
||||
|
@ -398,6 +534,39 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
|
|||
|
||||
/* utility functions */
|
||||
|
||||
function externalize_links($text){
|
||||
$i=0;$linkpos=true;
|
||||
while (true){ //Find a link
|
||||
$linkpos=strpos($text,"<a ",$i);
|
||||
if ($linkpos===false) break;
|
||||
$out.= substr($text,$i,$linkpos-$i)."<a target=\"_new\""; //Replace with target='_new'
|
||||
$i=$linkpos+3;
|
||||
}
|
||||
$out.=substr($text,$i);
|
||||
return $out;
|
||||
}
|
||||
|
||||
function image_as_link($text){
|
||||
/* This function depends on sanitized HTML - always use KSES or equivalent before using this */
|
||||
$i=0;
|
||||
while (true){ //Find an image
|
||||
$imgpos=strpos($text,"<img ",$i);
|
||||
if ($imgpos===false) break;
|
||||
$out.= substr($text,$i,$imgpos-$i)."<a href="; //Replace with link start
|
||||
$temp1=strpos($text,"src=",$imgpos)+5; //Find the image source
|
||||
$temp2=strpos($text,">",$imgpos)+1; //Or the end of the tag
|
||||
if ($temp1<$temp2){ //If source was found within tag
|
||||
$temp3=strpos($text,"\"",$temp1); //Find the end of source
|
||||
$out.=substr($text,$temp1,$temp3-$temp1); //output the source
|
||||
}
|
||||
$out.=">[Image link]</a>";
|
||||
$i=$temp2; //Now move to end of tag to continue
|
||||
}
|
||||
$out.=substr($text,$i); //Output the rest
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
function start_forum_table($headings, $span=NULL) {
|
||||
echo "
|
||||
<p style=\"text-align:center\">
|
||||
|
@ -422,17 +591,22 @@ function end_forum_table() {
|
|||
|
||||
// generate a "select" element from an array of values
|
||||
//
|
||||
function show_select_from_array($name, $array, $selection) {
|
||||
echo "<select name=\"$name\">";
|
||||
function select_from_array($name, $array, $selection) {
|
||||
$out= "<select name=\"$name\">";
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
echo "<option ";
|
||||
$out.= "<option ";
|
||||
if ($key == $selection) {
|
||||
echo "selected ";
|
||||
$out.= "selected ";
|
||||
}
|
||||
echo "value=\"", $key, "\">", $value, "</option>";
|
||||
$out.= "value=\"". $key. "\">". $value. "</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
$out.= "</select>";
|
||||
return $out;
|
||||
}
|
||||
|
||||
function show_select_from_array($name, $array, $selection) {
|
||||
echo select_from_array($name,$array,$selection);
|
||||
}
|
||||
|
||||
function show_forum_title($forum=NULL, $thread=NULL, $helpdesk=false) {
|
||||
|
|
|
@ -74,7 +74,7 @@ function show_page_nav($forum) {
|
|||
return $gotoStr;
|
||||
}
|
||||
|
||||
function show_forum($category, $forum, $start, $sort_style) {
|
||||
function show_forum($category, $forum, $start, $sort_style, $logged_in_user) {
|
||||
global $threads_per_page;
|
||||
$gotoStr = show_page_nav($forum);
|
||||
if ($category->is_helpdesk) {
|
||||
|
@ -105,6 +105,13 @@ function show_forum($category, $forum, $start, $sort_style) {
|
|||
|
||||
echo "</td>";
|
||||
$x = time_diff_str($thread->timestamp, time());
|
||||
|
||||
$logged_in_user=getThreadLastVisited($logged_in_user,$thread);
|
||||
if ($thread->timestamp>$logged_in_user->thread_last_visited){
|
||||
$unread="Unread post(s): ";
|
||||
} else {
|
||||
$unread="";
|
||||
}
|
||||
if ($category->is_helpdesk) {
|
||||
if ($thread->replies == 0) $x = "---";
|
||||
echo "<td align=left>
|
||||
|
@ -117,7 +124,7 @@ function show_forum($category, $forum, $start, $sort_style) {
|
|||
<td>", $thread->replies+1, "</td>
|
||||
<td align=left>", user_links($user), "</td>
|
||||
<td>", $thread->views, "</td>
|
||||
<td style=\"text-align:right\">", $x, "</td>
|
||||
<td style=\"text-align:right\">", $unread, " ", $x, "</td>
|
||||
";
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ function show_user_info_private($user) {
|
|||
row2("URL", $x);
|
||||
row2("Country", $user->country);
|
||||
row2("Postal code", $user->postal_code);
|
||||
if ($user->signature) {
|
||||
/* if ($user->signature) {
|
||||
$x = "<pre>".htmlspecialchars($user->signature)."</pre>";
|
||||
row2("Forums signature", $x);
|
||||
}
|
||||
}*/
|
||||
row2("", "<a href=edit_user_info_form.php>Edit account info</a>");
|
||||
|
||||
row1("Profile");
|
||||
|
@ -94,6 +94,9 @@ function show_user_info_private($user) {
|
|||
row2(PROJECT."<br><font size=-2>control project's resource share and customize screensaver graphics</font>",
|
||||
"<a href=prefs.php?subset=project>View or edit</a>"
|
||||
);
|
||||
row2("Forum<br><font size=-2>configure features and the appearance of the forum</font>",
|
||||
"<a href=\"edit_forum_preferences_form.php\">View or edit</a>"
|
||||
);
|
||||
}
|
||||
|
||||
// show summary of dynamic and static info (public)
|
||||
|
|
|
@ -89,6 +89,11 @@ function update_7_08_2004() {
|
|||
);
|
||||
}
|
||||
|
||||
//update_6_15_2004();
|
||||
function update_9_04_2004() {
|
||||
mysql_query(
|
||||
"insert into forum_preferences (userid, signature, posts) select user.id, user.signature, user.posts from user where user.posts > 0 or user.signature<>''");
|
||||
}
|
||||
|
||||
//update_9_04_2004();
|
||||
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/user.inc");
|
||||
require_once("../inc/profile.inc");
|
||||
require_once("../inc/util.inc");
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
|
||||
|
||||
|
||||
$avatar_url = mysql_escape_string($HTTP_POST_VARS["avatar_url"]);
|
||||
if (substr($avatar_url,0,4)!="http") $avatar_url="http://".$avatar_url;
|
||||
$avatar_type = intval($HTTP_POST_VARS["avatar_select"]);
|
||||
$newfile=IMAGE_PATH.$user->id."_avatar.jpg";
|
||||
if ($avatar_type<0 or $avatar_type>3) $avatar_type=0;
|
||||
if ($avatar_type==0){
|
||||
if (file_exists($newfile)){
|
||||
unset($newfile); //Delete the file on the server if the user
|
||||
//decides not to use an avatar
|
||||
// - or should it be kept?
|
||||
}
|
||||
$avatar_url="";
|
||||
} elseif ($avatar_type==2){
|
||||
if ($_FILES['picture']['tmp_name']!=""){
|
||||
$file=$_FILES['picture']['tmp_name'];
|
||||
$size = getImageSize($file);
|
||||
// print_r($size);flush();
|
||||
switch($size[2]) {
|
||||
case '2': // JPEG
|
||||
$image = imageCreateFromJPEG($file);
|
||||
break;
|
||||
case '3': // PNG
|
||||
$image = imageCreateFromPNG($file);
|
||||
break;
|
||||
default:
|
||||
//Not the right kind of file
|
||||
Echo "Error: Not the right kind of file";
|
||||
exit();
|
||||
}
|
||||
$width = $size[0];
|
||||
$height = $size[1];
|
||||
if ($width!=100||$height!=100){
|
||||
$image2 = scale_image($image, $width, $height, 100, 100);
|
||||
} else {
|
||||
$image2=$image;
|
||||
}
|
||||
ImageJPEG($image2, $newfile);
|
||||
}
|
||||
if (file_exists($newfile)){
|
||||
$avatar_url=IMAGE_URL.$user->id."_avatar.jpg"; //$newfile;
|
||||
} else {
|
||||
//User didn't upload a compatible file or it went lost on the server
|
||||
$avatar_url="";
|
||||
}
|
||||
}
|
||||
|
||||
$image_as_link = ($HTTP_POST_VARS["forum_images_as_links"]!="");
|
||||
$link_externally = ($HTTP_POST_VARS["forum_link_externally"]!="");
|
||||
$hide_avatars = ($HTTP_POST_VARS["forum_hide_avatars"]!="");
|
||||
|
||||
$no_signature_by_default=($HTTP_POST_VARS["signature_enable"]=="");
|
||||
$signature = mysql_escape_string($HTTP_POST_VARS["signature"]);
|
||||
|
||||
$forum_sort = $HTTP_POST_VARS["forum_sort"];
|
||||
$thread_sort = $HTTP_POST_VARS["thread_sort"];
|
||||
$faq_sort = $HTTP_POST_VARS["faq_sort"];
|
||||
$answer_sort = $HTTP_POST_VARS["answer_sort"];
|
||||
$forum_sorting=mysql_escape_string(implode("|",array($forum_sort,$thread_sort,$faq_sort,$answer_sort)));
|
||||
$has_prefs=mysql_query("select * from forum_preferences where userid='".$user->id."'");
|
||||
|
||||
$result = mysql_query(
|
||||
"update forum_preferences set
|
||||
avatar_type='".$avatar_type."',
|
||||
avatar='".$avatar_url."',
|
||||
images_as_links='".$image_as_link."',
|
||||
link_popup='".$link_externally."',
|
||||
hide_avatars='".$hide_avatars."',
|
||||
no_signature_by_default='".$no_signature_by_default."',
|
||||
sorting='".$forum_sorting."',
|
||||
signature='$signature'
|
||||
where userid=$user->id");
|
||||
if ($result) {
|
||||
echo mysql_error();
|
||||
Header("Location: home.php");
|
||||
} else {
|
||||
page_head("Forum preferences update");
|
||||
echo "Couldn't update forum preferences.<br>\n";
|
||||
echo mysql_error();
|
||||
page_tail();
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/forum.inc");
|
||||
require_once("../inc/util.inc");
|
||||
|
||||
db_init();
|
||||
$user = get_logged_in_user();
|
||||
$user = getForumPreferences($user);
|
||||
|
||||
page_head("Edit message board preferences");
|
||||
|
||||
start_table();
|
||||
row2("Reset preferences<br><font size=-2>Use this button to reset preferences to the defaults</font>",
|
||||
"<form method=post action=\"edit_forum_preferences_action.php\"><input type=\"submit\" value=\"Reset preferences\"></form>");
|
||||
echo "<form method=\"post\" action=\"edit_forum_preferences_action.php\" enctype=\"multipart/form-data\">";
|
||||
|
||||
|
||||
|
||||
if ($user->avatar_type==0){
|
||||
$zero_select="checked=true";
|
||||
} elseif($user->avatar_type==1){
|
||||
$one_select="checked=true";
|
||||
$avatar_url=$user->avatar;
|
||||
} elseif($user->avatar_type==2){
|
||||
$two_select="checked=true";
|
||||
}
|
||||
|
||||
row2("Avatar<br><font size=-2>The virtual representation of you on the message boards<br/>Note: Forced size of 100x100 pixels<br>format: jpg/png - size: at most 4k</font>",
|
||||
"
|
||||
<table>
|
||||
<tr><td><input type=\"radio\" name=\"avatar_select\" value=\"0\" ".$zero_select.">Don't use an avatar</td><td></td></tr>
|
||||
<!--<tr><td><input type=\"radio\" name=\"avatar_select\" value=\"1\" ".$one_select.">Use external avatar:</td><td><input name=\"avatar_url\" size=30 value=\"".$avatar_url."\"'></td></tr>-->
|
||||
<tr><td><input type=\"radio\" name=\"avatar_select\" value=\"2\" ".$two_select.">Use this uploaded avatar: <input type=\"file\" name=\"picture\"></td><td></td></tr>
|
||||
</table>
|
||||
"
|
||||
);
|
||||
row2("Sort styles<br><font size=-2>How to sort the replies in the message board and Q&A areas</font>",
|
||||
"
|
||||
<table>
|
||||
<tr><td>Message threadlist:</td><td>".select_from_array("forum_sort", $forum_sort_styles, getSortStyle($user,"forum"))."</td></tr>
|
||||
<tr><td>Message posts:</td><td>".select_from_array("thread_sort", $thread_sort_styles, getSortStyle($user,"thread"))."</td></tr>
|
||||
<tr><td>Q&A questionlist:</td><td>".select_from_array("faq_sort", $faq_sort_styles, getSortStyle($user,"faq"))."</td></tr>
|
||||
<tr><td>Q&A questions:</td><td>".select_from_array("answer_sort", $answer_sort_styles, getSortStyle($user,"answer"))."</td></tr>
|
||||
</table>"
|
||||
);
|
||||
|
||||
if ($user->link_popup==1){$forum_link_externally="checked=\"true\"";} else {$forum_link_externally="";}
|
||||
if ($user->images_as_links==1){$forum_image_as_link="checked=\"true\"";} else {$forum_image_as_link="";}
|
||||
if ($user->hide_avatars==1){$forum_hide_avatars="checked=\"true\"";} else {$forum_hide_avatars="";}
|
||||
|
||||
row2("Links and images".
|
||||
"<br><font size=-2>How to treat links and images in the forum</font></a>",
|
||||
"
|
||||
<input type=\"checkbox\" name=\"forum_link_externally\" ".$forum_link_externally."> Open links in new window/tab<br>
|
||||
<input type=\"checkbox\" name=\"forum_images_as_links\" ".$forum_image_as_link."> Show images as links<br>
|
||||
<input type=\"checkbox\" name=\"forum_hide_avatars\" ".$forum_hide_avatars."> Hide avatar images<br>
|
||||
"
|
||||
);
|
||||
|
||||
if ($user->no_signature_by_default==0){$enable_signature="checked=\"true\"";} else {$enable_signature="";}
|
||||
row2("Signature for message boards".
|
||||
"<br><a href=html.php><font size=-2>May contain HTML tags</font></a>",
|
||||
"
|
||||
<textarea name=signature rows=4 cols=50>".stripslashes($user->signature)."</textarea>
|
||||
<br><input type=\"checkbox\" name=\"signature_enable\" ".$enable_signature."> Attach signature by default"
|
||||
);
|
||||
if ($user->signature!=""){
|
||||
row2("Signature preview".
|
||||
"<br><font size=-2>This is how your signature will look in the forums</font>",
|
||||
sanitize_html(stripslashes($user->signature))
|
||||
);
|
||||
}
|
||||
row2("", "<input type=submit value='Update info'>");
|
||||
end_table();
|
||||
echo "</form>\n";
|
||||
page_tail();
|
||||
|
||||
?>
|
|
@ -10,9 +10,9 @@
|
|||
$url = $HTTP_POST_VARS["url"];
|
||||
$country = $HTTP_POST_VARS["country"];
|
||||
$postal_code = $HTTP_POST_VARS["postal_code"];
|
||||
$signature = $HTTP_POST_VARS["signature"];
|
||||
//$signature = $HTTP_POST_VARS["signature"];
|
||||
|
||||
$result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code', signature='$signature' where id=$user->id");
|
||||
$result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code' where id=$user->id");
|
||||
if ($result) {
|
||||
Header("Location: home.php");
|
||||
} else {
|
||||
|
|
|
@ -26,12 +26,13 @@ row2("Postal (ZIP) code<br><font size=-2>Optional</font>",
|
|||
"<input name=postal_code size=20 value='$user->postal_code'>"
|
||||
);
|
||||
|
||||
/*
|
||||
$x = "<textarea name=signature rows=4 cols=50>$user->signature</textarea>";
|
||||
row2("Signature for message boards".
|
||||
"<br><a href=html.php><font size=-2>May contain HTML tags</font></a>".
|
||||
"<br><font size=-2>Optional</font>",
|
||||
$x
|
||||
);
|
||||
);*/
|
||||
row2("", "<input type=submit value='Update info'>");
|
||||
end_table();
|
||||
echo "</form>\n";
|
||||
|
|
|
@ -26,18 +26,20 @@ $category = getCategory($forum->category);
|
|||
if ($category->is_helpdesk) {
|
||||
$sort_style = $_GET['sort'];
|
||||
if (!$sort_style) {
|
||||
$sort_style = $_COOKIE['hd_sort_style'];
|
||||
$sort_style = getSortStyle($logged_in_user,"faq");
|
||||
} else {
|
||||
setcookie('hd_sort_style', $sort_style, time()+3600*24*365);
|
||||
setSortStyle($logged_in_user,"faq",$sort_style);
|
||||
}
|
||||
if (!$sort_style) $sort_style = 'activity';
|
||||
page_head('Help Desk');
|
||||
} else {
|
||||
$sort_style = $_GET['sort'];
|
||||
if (!$sort_style) {
|
||||
$sort_style = $_COOKIE['forum_sort_style'];
|
||||
$sort_style = getSortStyle($logged_in_user,"forum");
|
||||
//$sort_style = $_COOKIE['forum_sort_style'];
|
||||
} else {
|
||||
setcookie('forum_sort_style', $sort_style, time()+3600*24*365);
|
||||
setSortStyle($logged_in_user, "forum",$sort_style);
|
||||
//setcookie('forum_sort_style', $sort_style, time()+3600*24*365);
|
||||
}
|
||||
if (!$sort_style) $sort_style = 'modified-new';
|
||||
page_head('Message boards : '.$forum->title);
|
||||
|
@ -73,7 +75,7 @@ echo "<input type=submit value=OK></td>\n";
|
|||
|
||||
echo "</tr>\n</table>\n</form>";
|
||||
|
||||
show_forum($category, $forum, $start, $sort_style);
|
||||
show_forum($category, $forum, $start, $sort_style, $logged_in_user);
|
||||
|
||||
page_tail();
|
||||
|
||||
|
|
|
@ -4,15 +4,17 @@ require_once('../inc/forum.inc');
|
|||
require_once('../inc/util.inc');
|
||||
require_once('../inc/subscribe.inc');
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_POST['title']) && !empty($_POST['content'])) {
|
||||
$_GET['id'] = stripslashes(strip_tags($_GET['id']));
|
||||
$logged_in_user = get_logged_in_user(true);
|
||||
$logged_in_user = getForumPreferences($logged_in_user);
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_POST['title']) && !empty($_POST['content'])) {
|
||||
$_GET['id'] = stripslashes(strip_tags($_GET['id']));
|
||||
|
||||
$user = get_logged_in_user(true);
|
||||
|
||||
if ($_POST['add_signature']=="add_it") {
|
||||
$forum_signature = "\n".$user->signature;
|
||||
$forum_signature = "\n".$logged_in_user->signature;
|
||||
}
|
||||
$threadID = createThread($_GET['id'], $user->id, $_POST['title'], $_POST['content'].$forum_signature);
|
||||
$threadID = createThread($_GET['id'], $logged_in_user->id, $_POST['title'], $_POST['content'].$forum_signature);
|
||||
if (!$threadID) {
|
||||
page_head("Can't create thread");
|
||||
echo "Title is possibly missing";
|
||||
|
@ -31,7 +33,6 @@ if (!empty($_GET['id'])) {
|
|||
exit();
|
||||
}
|
||||
|
||||
$logged_in_user = get_logged_in_user(true);
|
||||
|
||||
// TODO: Write a function to do this.
|
||||
|
||||
|
@ -97,8 +98,9 @@ if ($category->is_helpdesk) {
|
|||
|
||||
|
||||
$y = "<textarea name=content rows=12 cols=54></textarea>";
|
||||
if ($logged_in_user->no_signature_by_default==0){$enable_signature="checked=\"true\"";} else {$enable_signature="";}
|
||||
row2($x, $y);
|
||||
row2("", "<input name=add_signature value=add_it checked=true type=checkbox>Add my signature to this post");
|
||||
row2("", "<input name=add_signature value=add_it ".$enable_signature." type=checkbox>Add my signature to this post");
|
||||
row2("", "<input type=submit value=\"OK\">");
|
||||
|
||||
end_forum_table();
|
||||
|
|
|
@ -4,6 +4,10 @@ require_once('../inc/forum.inc');
|
|||
require_once('../inc/util.inc');
|
||||
require_once('../inc/subscribe.inc');
|
||||
|
||||
$logged_in_user = get_logged_in_user(true);
|
||||
$logged_in_user = getForumPreferences($logged_in_user);
|
||||
|
||||
|
||||
if (!empty($_GET['thread']) && !empty($_POST['content'])) {
|
||||
$_GET['thread'] = stripslashes($_GET['thread']);
|
||||
|
||||
|
@ -13,18 +17,15 @@ if (!empty($_GET['thread']) && !empty($_POST['content'])) {
|
|||
$parent_post = NULL;
|
||||
}
|
||||
|
||||
$user = get_logged_in_user(true);
|
||||
|
||||
if ($_POST['add_signature']=="add_it"){
|
||||
$forum_signature = "\n".$user->signature;
|
||||
$forum_signature = "\n".$logged_in_user->signature;
|
||||
}
|
||||
replyToThread($_GET['thread'], $user->id, $_POST['content'].$forum_signature, $parent_post);
|
||||
replyToThread($_GET['thread'], $logged_in_user->id, $_POST['content'].$forum_signature, $parent_post);
|
||||
notify_subscribers($_GET['thread']);
|
||||
|
||||
header('Location: forum_thread.php?id='.$_GET['thread']);
|
||||
}
|
||||
|
||||
$logged_in_user = get_logged_in_user(true);
|
||||
|
||||
if (empty($_GET['thread'])) {
|
||||
// TODO: Standard error page.
|
||||
|
@ -94,10 +95,11 @@ function show_message_row($thread, $category, $post=NULL) {
|
|||
|
||||
echo "' method=post><textarea name=\"content\" rows=\"18\" cols=\"80\">";
|
||||
if ($post) echo quote_text(stripslashes($post->content), 80);
|
||||
if ($logged_in_user->no_signature_by_default==0){$enable_signature="checked=\"true\"";} else {$enable_signature="";}
|
||||
echo "</textarea><p>
|
||||
<input type=\"submit\" value=\"Post reply\">
|
||||
|
||||
<input name=add_signature value=add_it checked=true type=checkbox>Add my signature to this reply
|
||||
<input name=add_signature value=add_it ".$enable_signature." type=checkbox>Add my signature to this reply
|
||||
|
||||
</form>
|
||||
";
|
||||
|
|
|
@ -26,17 +26,25 @@ $forum = getForum($thread->forum);
|
|||
$category = getCategory($forum->category);
|
||||
|
||||
$logged_in_user = get_logged_in_user(false);
|
||||
|
||||
if (!$sort_style) {
|
||||
$sort_style = $_COOKIE['thread_sort_style'];
|
||||
} else {
|
||||
setcookie('thread_sort_style', $sort_style, time()+3600*24*365);
|
||||
}
|
||||
$logged_in_user = getForumPreferences($logged_in_user);
|
||||
|
||||
if ($category->is_helpdesk) {
|
||||
page_head(PROJECT.': Questions and problems');
|
||||
if (!$sort_style) {
|
||||
$sort_style = getSortStyle($logged_in_user,"answer");
|
||||
} else {
|
||||
setSortStyle($logged_in_user,"answer", $sort_style);
|
||||
//);setcookie('thread_sort_style', $sort_style, time()+3600*24*365);
|
||||
}
|
||||
|
||||
} else {
|
||||
page_head(PROJECT.': Message boards');
|
||||
if (!$sort_style) {
|
||||
$sort_style = getSortStyle($logged_in_user,"thread");
|
||||
} else {
|
||||
setSortStyle($logged_in_user,"thread", $sort_style);
|
||||
//);setcookie('thread_sort_style', $sort_style, time()+3600*24*365);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Constant for default sort style and filter values.
|
||||
|
@ -91,7 +99,7 @@ echo "</td>";
|
|||
|
||||
echo "<td align=right style=\"border:0px\">";
|
||||
if ($category->is_helpdesk) {
|
||||
show_select_from_array("sort", $answer_sort_styles, $sort_styles);
|
||||
show_select_from_array("sort", $answer_sort_styles, $sort_style);
|
||||
} else {
|
||||
echo "Sort ";
|
||||
show_select_from_array("sort", $thread_sort_styles, $sort_style);
|
||||
|
|
Loading…
Reference in New Issue