2004-09-04 23:37:49 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-11-13 17:18:34 +00:00
|
|
|
|
2011-02-09 22:11:34 +00:00
|
|
|
require_once("../inc/util.inc");
|
2005-01-06 11:47:44 +00:00
|
|
|
require_once("../inc/forum.inc");
|
2006-06-16 23:53:56 +00:00
|
|
|
require_once("../inc/image.inc"); // Avatar scaling
|
2007-03-29 18:58:17 +00:00
|
|
|
|
|
|
|
if (post_str("account_key", true) != null) {
|
|
|
|
$user = lookup_user_auth(post_str("account_key"));
|
|
|
|
$rpc = true;
|
|
|
|
} else {
|
2007-11-13 17:18:34 +00:00
|
|
|
$user = get_logged_in_user();
|
2007-03-29 18:58:17 +00:00
|
|
|
$rpc = false;
|
|
|
|
}
|
2007-11-13 17:18:34 +00:00
|
|
|
BoincForumPrefs::lookup($user);
|
2006-06-16 23:53:56 +00:00
|
|
|
|
2007-11-29 16:47:56 +00:00
|
|
|
if (post_str("action", true)=="reset_confirm"){
|
2011-08-25 22:12:48 +00:00
|
|
|
page_head(tra("Confirm reset"));
|
|
|
|
echo tra("This action will erase any changes you have made in your community preferences. To cancel, click your browser's Back button.")."
|
2007-11-29 16:47:56 +00:00
|
|
|
<p>
|
|
|
|
<form action=edit_forum_preferences_action.php method=post>
|
|
|
|
<input type=hidden name=action value=reset>
|
2011-08-25 22:12:48 +00:00
|
|
|
<input type=submit value=\"".tra("Reset preferences")."\">
|
2007-11-29 16:47:56 +00:00
|
|
|
</form>
|
|
|
|
";
|
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2007-11-19 02:17:57 +00:00
|
|
|
// If the user has requested a reset of preferences;
|
|
|
|
// preserve a few fields.
|
2007-11-13 17:18:34 +00:00
|
|
|
//
|
2006-06-16 23:53:56 +00:00
|
|
|
if (post_str("action", true)=="reset"){
|
2007-11-13 17:18:34 +00:00
|
|
|
$posts = $user->prefs->posts;
|
2007-11-30 00:32:29 +00:00
|
|
|
$last_post = $user->prefs->last_post;
|
|
|
|
$rated_posts = $user->prefs->rated_posts;
|
2007-11-13 17:18:34 +00:00
|
|
|
$banished_until = $user->prefs->banished_until;
|
|
|
|
$special_user = $user->prefs->special_user;
|
|
|
|
$user->prefs->delete();
|
2007-11-30 00:32:29 +00:00
|
|
|
unset($user->prefs);
|
|
|
|
BoincForumPrefs::lookup($user, true);
|
|
|
|
$user->prefs->update("posts=$posts, last_post=$last_post, rated_posts='$rated_posts', banished_until=$banished_until, special_user='$special_user'");
|
2007-09-09 19:01:05 +00:00
|
|
|
Header("Location: edit_forum_preferences_form.php");
|
2006-06-16 23:53:56 +00:00
|
|
|
exit;
|
2006-04-14 22:25:55 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$avatar_type = post_int("avatar_select");
|
2007-11-13 17:18:34 +00:00
|
|
|
$newfile=IMAGE_PATH.$user->id."_avatar.jpg";
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
// Update the user avatar
|
2004-12-20 18:29:15 +00:00
|
|
|
if ($avatar_type<0 or $avatar_type>3) $avatar_type=0;
|
|
|
|
if ($avatar_type==0){
|
|
|
|
if (file_exists($newfile)){
|
2007-11-13 17:18:34 +00:00
|
|
|
// Delete the file on the server if the user
|
|
|
|
// decides not to use an avatar
|
|
|
|
//
|
|
|
|
unlink($newfile);
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
|
|
|
$avatar_url="";
|
2008-07-19 17:31:10 +00:00
|
|
|
} elseif ($avatar_type == 1) {
|
2011-08-29 05:37:52 +00:00
|
|
|
$avatar_url = "http://www.gravatar.com/avatar/".md5($user->email_addr)."?s=100&d=identicon";
|
2004-12-20 18:29:15 +00:00
|
|
|
} elseif ($avatar_type==2){
|
2007-03-29 18:58:17 +00:00
|
|
|
if (($rpc && (post_str("avatar_url", true) != null)) || ($_FILES['picture']['tmp_name']!="")) {
|
|
|
|
if ($_FILES['picture']['tmp_name']!="") {
|
|
|
|
$file = $_FILES['picture']['tmp_name'];
|
|
|
|
} else {
|
|
|
|
// Remote image. Download and store locally
|
|
|
|
$file = post_str("avatar_url");
|
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
$size = getImageSize($file);
|
|
|
|
if ($size[2]!=2 and $size[2]!=3){
|
|
|
|
//Not the right kind of file
|
2011-08-25 22:12:48 +00:00
|
|
|
error_page(tra("Error: Not the right kind of file, only PNG and JPEG are supported."));
|
2004-09-14 21:29:52 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
$width = $size[0];
|
|
|
|
$height = $size[1];
|
|
|
|
$image2 = intelligently_scale_image($file, 100, 100);
|
|
|
|
ImageJPEG($image2, $newfile);
|
|
|
|
}
|
|
|
|
if (file_exists($newfile)){
|
2007-11-17 20:30:33 +00:00
|
|
|
$avatar_url=IMAGE_URL.$user->id."_avatar.jpg"; //$newfile;
|
2004-12-20 18:29:15 +00:00
|
|
|
} else {
|
|
|
|
//User didn't upload a compatible file or it went lost on the server
|
2004-09-14 21:29:52 +00:00
|
|
|
$avatar_url="";
|
2004-09-04 23:37:49 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2004-10-10 03:04:29 +00:00
|
|
|
|
2007-11-13 17:18:34 +00:00
|
|
|
$images_as_links = ($_POST["forum_images_as_links"]!="")?1:0;
|
|
|
|
$link_popup = ($_POST["forum_link_popup"]!="")?1:0;
|
|
|
|
$hide_avatars = ($_POST["forum_hide_avatars"]!="")?1:0;
|
|
|
|
$hide_signatures = ($_POST["forum_hide_signatures"]!="")?1:0;
|
2008-10-05 16:00:11 +00:00
|
|
|
$highlight_special = ($_POST["forum_highlight_special"]!="")?1:0;
|
2007-11-13 17:18:34 +00:00
|
|
|
$jump_to_unread = ($_POST["forum_jump_to_unread"]!="")?1:0;
|
|
|
|
$ignore_sticky_posts = ($_POST["forum_ignore_sticky_posts"]!="")?1:0;
|
|
|
|
$no_signature_by_default = ($_POST["signature_by_default"]!="")?0:1;
|
2007-12-30 22:02:16 +00:00
|
|
|
$pm_notification = post_int("pm_notification");
|
2008-07-08 17:42:52 +00:00
|
|
|
$signature = post_str("signature", true);
|
2004-12-20 18:29:15 +00:00
|
|
|
if (strlen($signature)>250) {
|
2011-08-25 22:12:48 +00:00
|
|
|
error_page(tra("Your signature was too long, please keep it less than 250 characters."));
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
$forum_sort = post_int("forum_sort");
|
|
|
|
$thread_sort = post_int("thread_sort");
|
2007-11-13 17:18:34 +00:00
|
|
|
$display_wrap_postcount = post_int("forum_display_wrap_postcount");
|
2012-07-11 05:27:31 +00:00
|
|
|
if ($display_wrap_postcount<1) $display_wrap_postcount=1;
|
2007-11-13 17:18:34 +00:00
|
|
|
|
|
|
|
$signature = BoincDb::escape_string($signature);
|
|
|
|
|
2012-07-11 05:27:31 +00:00
|
|
|
$user->prefs->update("images_as_links=$images_as_links, link_popup=$link_popup, hide_avatars=$hide_avatars, hide_signatures=$hide_signatures, highlight_special=$highlight_special, jump_to_unread=$jump_to_unread, ignore_sticky_posts=$ignore_sticky_posts, no_signature_by_default=$no_signature_by_default, pm_notification=$pm_notification, avatar='$avatar_url', signature='$signature', forum_sorting=$forum_sort, thread_sorting=$thread_sort, display_wrap_postcount=$display_wrap_postcount");
|
2007-11-13 17:18:34 +00:00
|
|
|
|
2004-12-20 18:29:15 +00:00
|
|
|
|
2006-09-19 12:57:57 +00:00
|
|
|
$add_user_to_filter = ($_POST["add_user_to_filter"]!="");
|
2006-04-13 22:17:23 +00:00
|
|
|
if ($add_user_to_filter){
|
2006-09-19 12:57:57 +00:00
|
|
|
$user_to_add = trim($_POST["forum_filter_user"]);
|
2005-01-06 11:47:44 +00:00
|
|
|
if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){
|
2007-11-13 17:18:34 +00:00
|
|
|
$other_user = BoincUser::lookup_id($user_to_add);
|
|
|
|
if (!$other_user) {
|
2011-08-25 22:12:48 +00:00
|
|
|
echo tra("No such user: %1", $other_user);
|
2007-11-13 17:18:34 +00:00
|
|
|
} else {
|
|
|
|
add_ignored_user($user, $other_user);
|
|
|
|
}
|
2005-01-06 11:47:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Or remove some from the ignore list
|
2007-11-13 17:18:34 +00:00
|
|
|
//
|
|
|
|
$ignored_users = get_ignored_list($user);
|
2006-06-16 23:53:56 +00:00
|
|
|
for ($i=0;$i<sizeof($ignored_users);$i++){
|
2006-09-19 12:57:57 +00:00
|
|
|
if ($_POST["remove".trim($ignored_users[$i])]!=""){
|
2007-11-23 00:19:48 +00:00
|
|
|
$other_user = BoincUser::lookup_id($ignored_users[$i]);
|
2007-11-13 17:18:34 +00:00
|
|
|
if (!$other_user) {
|
2011-08-25 22:12:48 +00:00
|
|
|
echo tra("No such user: %1", $other_user);
|
2007-11-13 17:18:34 +00:00
|
|
|
} else {
|
|
|
|
remove_ignored_user($user, $other_user);
|
|
|
|
}
|
2006-04-14 22:25:55 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
|
2007-03-29 18:58:17 +00:00
|
|
|
if ($rpc == false) {
|
2007-11-13 17:18:34 +00:00
|
|
|
// If we get down here everything went ok
|
2007-11-20 19:23:26 +00:00
|
|
|
// redirect the user to the setup page again
|
|
|
|
//
|
2007-03-29 18:58:17 +00:00
|
|
|
Header("Location: edit_forum_preferences_form.php");
|
|
|
|
} else {
|
|
|
|
echo "<status>\n";
|
|
|
|
echo " <success>1</success>\n";
|
|
|
|
echo "</status>\n";
|
|
|
|
}
|
2004-09-04 23:37:49 +00:00
|
|
|
|
|
|
|
?>
|