1<?php 2// This file is part of BOINC. 3// http://boinc.berkeley.edu 4// Copyright (C) 2008 University of California 5// 6// BOINC is free software; you can redistribute it and/or modify it 7// under the terms of the GNU Lesser General Public License 8// as published by the Free Software Foundation, 9// either version 3 of the License, or (at your option) any later version. 10// 11// BOINC is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14// See the GNU Lesser General Public License for more details. 15// 16// You should have received a copy of the GNU Lesser General Public License 17// along with BOINC. If not, see <http://www.gnu.org/licenses/>. 18 19require_once("../inc/util.inc"); 20require_once("../inc/forum.inc"); 21require_once("../inc/image.inc"); // Avatar scaling 22 23if (post_str("account_key", true) != null) { 24 $user = BoincUser::lookup_auth(post_str("account_key")); 25 $rpc = true; 26} else { 27 $user = get_logged_in_user(); 28 $rpc = false; 29} 30BoincForumPrefs::lookup($user); 31 32if (post_str("action", true)=="reset_confirm"){ 33 page_head(tra("Confirm reset")); 34 echo tra("This action will erase any changes you have made in your community preferences. To cancel, click your browser's Back button.")." 35 <p> 36 <form action=edit_forum_preferences_action.php method=post> 37 <input type=hidden name=action value=reset> 38 <input class=\"btn btn-warning\" type=submit value=\"".tra("Reset preferences")."\"> 39 </form> 40 "; 41 page_tail(); 42 exit(); 43} 44 45// If the user has requested a reset of preferences; 46// preserve a few fields. 47// 48if (post_str("action", true)=="reset"){ 49 $posts = $user->prefs->posts; 50 $last_post = $user->prefs->last_post; 51 $rated_posts = $user->prefs->rated_posts; 52 $banished_until = $user->prefs->banished_until; 53 $special_user = $user->prefs->special_user; 54 $user->prefs->delete(); 55 unset($user->prefs); 56 BoincForumPrefs::lookup($user, true); 57 $user->prefs->update("posts=$posts, last_post=$last_post, rated_posts='$rated_posts', banished_until=$banished_until, special_user='$special_user'"); 58 Header("Location: edit_forum_preferences_form.php"); 59 exit; 60} 61 62$pmn = post_int("pm_notification"); 63if ($pmn != $user->prefs->pm_notification) { 64 $user->prefs->update("pm_notification=$pmn"); 65} 66 67if (!DISABLE_FORUMS) { 68 69$avatar_type = post_int("avatar_select"); 70$newfile=IMAGE_PATH.$user->id."_avatar.jpg"; 71 72// Update the user avatar 73if ($avatar_type<0 or $avatar_type>3) $avatar_type=0; 74if ($avatar_type==0){ 75 if (file_exists($newfile)){ 76 // Delete the file on the server if the user 77 // decides not to use an avatar 78 // 79 unlink($newfile); 80 } 81 $avatar_url=""; 82} elseif ($avatar_type == 1) { 83 $avatar_url = "//www.gravatar.com/avatar/".md5($user->email_addr)."?s=100&d=identicon"; 84} elseif ($avatar_type==2){ 85 if (($rpc && (post_str("avatar_url", true) != null)) || ($_FILES['picture']['tmp_name']!="")) { 86 if ($_FILES['picture']['tmp_name']!="") { 87 $file = $_FILES['picture']['tmp_name']; 88 } else { 89 // Remote image. Download and store locally 90 $file = post_str("avatar_url"); 91 } 92 $size = getImageSize($file); 93 if ($size[2]!=2 and $size[2]!=3){ 94 //Not the right kind of file 95 error_page(tra("Error: Not the right kind of file, only PNG and JPEG are supported.")); 96 } 97 $width = $size[0]; 98 $height = $size[1]; 99 $image2 = intelligently_scale_image($file, 100, 100); 100 ImageJPEG($image2, $newfile); 101 } 102 if (file_exists($newfile)){ 103 $avatar_url=IMAGE_URL.$user->id."_avatar.jpg"; //$newfile; 104 } else { 105 //User didn't upload a compatible file or it went lost on the server 106 $avatar_url=""; 107 } 108} 109 110$images_as_links = (isset($_POST["forum_images_as_links"]) && $_POST["forum_images_as_links"]!="")?1:0; 111$link_popup = (isset($_POST["forum_link_popup"]) && $_POST["forum_link_popup"]!="")?1:0; 112$hide_avatars = (isset($_POST["forum_hide_avatars"]) && $_POST["forum_hide_avatars"]!="")?1:0; 113$hide_signatures = (isset($_POST["forum_hide_signatures"]) && $_POST["forum_hide_signatures"]!="")?1:0; 114$highlight_special = (isset($_POST["forum_highlight_special"]) && $_POST["forum_highlight_special"]!="")?1:0; 115$jump_to_unread = (isset($_POST["forum_jump_to_unread"]) && $_POST["forum_jump_to_unread"]!="")?1:0; 116$ignore_sticky_posts = (isset($_POST["forum_ignore_sticky_posts"]) && $_POST["forum_ignore_sticky_posts"]!="")?1:0; 117$no_signature_by_default = (isset($_POST["signature_by_default"]) && $_POST["signature_by_default"]!="")?0:1; 118$signature = post_str("signature", true); 119if (strlen($signature)>250) { 120 error_page(tra("Your signature was too long, please keep it less than 250 characters.")); 121} 122$forum_sort = post_int("forum_sort"); 123$thread_sort = post_int("thread_sort"); 124$display_wrap_postcount = post_int("forum_display_wrap_postcount"); 125if ($display_wrap_postcount<1) $display_wrap_postcount=1; 126 127$signature = BoincDb::escape_string($signature); 128 129$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, avatar='$avatar_url', signature='$signature', forum_sorting=$forum_sort, thread_sorting=$thread_sort, display_wrap_postcount=$display_wrap_postcount"); 130 131} // DISABLE_FORUMS 132 133$add_user_to_filter = (isset($_POST["add_user_to_filter"]) && $_POST["add_user_to_filter"]!=""); 134if ($add_user_to_filter){ 135 $user_to_add = trim($_POST["forum_filter_user"]); 136 if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ 137 $other_user = BoincUser::lookup_id($user_to_add); 138 if (!$other_user) { 139 echo tra("No such user:")." ".$user_to_add; 140 } else { 141 add_ignored_user($user, $other_user); 142 } 143 } 144} 145 146// Or remove some from the ignore list 147// 148$ignored_users = get_ignored_list($user); 149for ($i=0;$i<sizeof($ignored_users);$i++){ 150 $remove = "remove".trim($ignored_users[$i]); 151 if (isset($_POST[$remove]) && $_POST[$remove]!=""){ 152 $other_user = BoincUser::lookup_id($ignored_users[$i]); 153 if (!$other_user) { 154 echo tra("No such user:")." ".$ignored_users[$j]; 155 } else { 156 remove_ignored_user($user, $other_user); 157 } 158 } 159} 160 161 162if ($rpc == false) { 163 // If we get down here everything went ok 164 // redirect the user to the setup page again 165 // 166 Header("Location: edit_forum_preferences_form.php"); 167} else { 168 echo "<status>\n"; 169 echo " <success>1</success>\n"; 170 echo "</status>\n"; 171} 172 173?> 174