2007-03-25 03:25:57 +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-03-25 03:25:57 +00:00
|
|
|
/***********************************************************************\
|
|
|
|
* Manage user settings
|
|
|
|
*
|
|
|
|
* Displays user settings, allows one to control special user status
|
2007-03-29 19:17:13 +00:00
|
|
|
* and forum suspension (banishment). Put this in html/ops,
|
|
|
|
* (or could be used by moderators for bans < 24 hrs).
|
2007-03-25 03:25:57 +00:00
|
|
|
*
|
2007-03-29 19:17:13 +00:00
|
|
|
* @(#) $Id$
|
2007-03-25 03:25:57 +00:00
|
|
|
\***********************************************************************/
|
|
|
|
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/user.inc");
|
2007-11-02 14:43:02 +00:00
|
|
|
require_once("../inc/team.inc");
|
2007-03-25 03:25:57 +00:00
|
|
|
require_once("../inc/forum.inc");
|
|
|
|
require_once("../inc/util_ops.inc");
|
|
|
|
require_once("../inc/profile.inc");
|
|
|
|
require_once("../project/project.inc");
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
db_init();
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
$is_admin = true;
|
|
|
|
$Nbf = sizeof($special_user_bitfield);
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-11-02 14:43:02 +00:00
|
|
|
|
|
|
|
// Delete a user (or at least try to)
|
|
|
|
function delete_user($user){
|
|
|
|
global $delete_problem;
|
|
|
|
|
|
|
|
if( !empty($user->teamid) ){
|
|
|
|
user_quit_team($user);
|
|
|
|
#$delete_problem .= "Removed user from team.<br/>";
|
|
|
|
}
|
|
|
|
if( $user->has_profile ){
|
|
|
|
mysql_query("DELETE FROM profile WHERE userid = $user->id");
|
|
|
|
delete_user_pictures($user->id);
|
|
|
|
mysql_query("UPDATE user SET has_profile=0 WHERE id=$user->id");
|
|
|
|
#$delete_problem .= "Deleted profile.<br/>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $user->total_credit > 0.0 ){
|
|
|
|
$delete_problem .= "Cannot delete user: User has credit.<br/>";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't delete user if they have any outstanding Results
|
|
|
|
//
|
|
|
|
$q = "SELECT COUNT(*) AS count FROM result WHERE userid=".$user->id;
|
|
|
|
$result = mysql_query($q);
|
|
|
|
$c = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
if($c->count){
|
|
|
|
$delete_problem .= "Cannot delete user: User has ". $c->count.
|
|
|
|
" Results in the database.<br/>";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't delete user if they have posted to the forums
|
|
|
|
//
|
|
|
|
$q = "SELECT COUNT(*) AS count FROM post WHERE user=".$user->id;
|
|
|
|
$result = mysql_query($q);
|
|
|
|
$c = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
if($c->count){
|
|
|
|
$delete_problem .= "Cannot delete user: User has ". $c->count.
|
|
|
|
" forum posts.<br/>";
|
|
|
|
}
|
|
|
|
if($delete_problem) return false;
|
|
|
|
|
|
|
|
$q = "DELETE FROM user WHERE id=".$user->id;
|
|
|
|
$result = mysql_query($q);
|
|
|
|
$delete_problem .= "User ".$user->id." deleted.";
|
|
|
|
unset($user);
|
|
|
|
|
|
|
|
}
|
|
|
|
$delete_problem="";
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
/**
|
|
|
|
* Process user search form
|
|
|
|
*/
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
$matches="";
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( isset($_POST['search_submit']) ){
|
|
|
|
$search_name = post_str('search_text');
|
|
|
|
$search_name = process_user_text(strip_tags($search_name));
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( !empty($search_name) ){
|
|
|
|
$result = mysql_query("SELECT * FROM user WHERE name='$search_name'");
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( mysql_num_rows($result)==1 ) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$q = "SELECT * FROM user WHERE name LIKE '%".$search_name."%'";
|
|
|
|
$result = mysql_query($q);
|
|
|
|
if( mysql_num_rows($result)==1 ) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
}
|
|
|
|
if( mysql_num_rows($result)>1 ) {
|
|
|
|
while( $row = mysql_fetch_object($result) ){
|
|
|
|
if( !empty($matches) ) $matches .= ", ";
|
|
|
|
$matches .= $row->name;
|
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
/**
|
|
|
|
* Look up the user
|
|
|
|
*/
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
$id = get_int("userid", true);
|
|
|
|
if( empty($id) ) $id = post_int("userid", true);
|
|
|
|
if( !empty($id) ){
|
|
|
|
$user = lookup_user_id($id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// but clear if page was reset (forcing search form)
|
|
|
|
|
|
|
|
if( isset($_POST['reset_page']) ){
|
|
|
|
unset($user);
|
2007-03-25 03:25:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process special user settings
|
|
|
|
*/
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( isset($_POST['special_user']) && $user && $is_admin ){
|
2007-03-25 03:25:57 +00:00
|
|
|
$bits="";
|
|
|
|
for($i=0;$i<$Nbf;$i++) {
|
|
|
|
$bits .= $_POST['special_user_'.$i] ? "1" : "0" ;
|
|
|
|
}
|
|
|
|
$q = "UPDATE forum_preferences SET special_user=\"$bits\" WHERE userid=$id";
|
|
|
|
mysql_query($q);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process a suspension:
|
|
|
|
*/
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( isset($_POST['suspend_submit']) && !empty($user) && $is_admin ){
|
2007-03-25 03:25:57 +00:00
|
|
|
$dt = post_int('suspend_for',true);
|
2007-03-29 19:17:13 +00:00
|
|
|
|
|
|
|
if( $is_admin || ($is_mod && $dt < 86400) ){
|
2007-03-25 03:25:57 +00:00
|
|
|
$reason = $_POST['suspend_reason'];
|
|
|
|
if( $dt > 0 && empty($reason) ) {
|
|
|
|
error_page("You must supply a reason for a suspension.
|
|
|
|
<p><a href='$self?userid=$user->id'>Try again</a>");
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-03-25 03:25:57 +00:00
|
|
|
if( is_numeric($dt) ) {
|
|
|
|
$t = time()+$dt;
|
|
|
|
$q = "UPDATE forum_preferences SET banished_until=$t WHERE userid=$id";
|
|
|
|
mysql_query($q);
|
|
|
|
|
|
|
|
/* put a timestamp in wiki to trigger re-validation of credentials */
|
|
|
|
|
|
|
|
if( function_exists('touch_wiki_user') ){
|
|
|
|
touch_wiki_user($user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send suspension e-mail to user and administrators */
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( $dt>0 ){
|
2007-03-25 03:25:57 +00:00
|
|
|
$subject = PROJECT." posting privileges suspended for ". $user->name;
|
|
|
|
$body = "
|
|
|
|
Forum posting privileges for the " .PROJECT. " user \"".$user->name."\"
|
|
|
|
have been suspended for " .time_diff($dt). " by ".$logged_in_user->name.".
|
|
|
|
The reason given was:
|
|
|
|
|
|
|
|
$reason
|
|
|
|
|
|
|
|
The suspension will end at " .time_str($t)."\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$subject = PROJECT." user ". $user->name. " unsuspended";
|
|
|
|
$body = "
|
|
|
|
Forum posting privileges for the " .PROJECT. " user \"".$user->name."\"
|
|
|
|
have been restored by ".$logged_in_user->name."\n";
|
|
|
|
if($reason) $body.="The reason given was:\n\n $reason\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
send_email($user, $subject, $body);
|
|
|
|
|
|
|
|
$emails = explode(",", POST_REPORT_EMAILS);
|
|
|
|
foreach ($emails as $email) {
|
|
|
|
$admin->email_addr = $email;
|
|
|
|
send_email($admin, $subject, $body);
|
|
|
|
}
|
2007-03-29 19:17:13 +00:00
|
|
|
}//numerical($dt)
|
2007-03-25 03:25:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}// suspend_submit
|
|
|
|
|
|
|
|
|
2007-11-02 14:43:02 +00:00
|
|
|
// Process a delete request. Empty user will trigger search form.
|
|
|
|
//
|
|
|
|
if( isset($_POST['delete_user']) && !empty($user)){
|
|
|
|
delete_user($user);
|
|
|
|
}
|
|
|
|
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
// Now update from whatever might have been set above
|
2007-03-25 03:25:57 +00:00
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( !empty($user) ) {
|
2007-12-19 21:28:58 +00:00
|
|
|
BoincForumPrefs::lookup($user);
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
/********************************
|
|
|
|
* Output:
|
|
|
|
*/
|
|
|
|
|
|
|
|
admin_page_head("User Management: $user->name");
|
|
|
|
|
2007-07-05 19:37:33 +00:00
|
|
|
echo "<h2>User Management</h2>\n";
|
2007-03-29 19:17:13 +00:00
|
|
|
|
2007-03-25 03:25:57 +00:00
|
|
|
if (!defined("POST_REPORT_EMAILS")) {
|
2007-03-29 19:17:13 +00:00
|
|
|
echo "<p><font color='RED'>
|
2007-03-25 03:25:57 +00:00
|
|
|
There is no addministrative e-mail address defined for reporting problems
|
|
|
|
or abuse in the forums. Please define POST_REPORT_EMAILS in project.inc
|
|
|
|
</font></p>\n";
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
echo "<form name='manage_user' action='$self' method='POST'>
|
2007-03-29 19:17:13 +00:00
|
|
|
<input type='hidden' name='userid' value='". $user->id."'> \n";
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
start_table();
|
2007-03-29 19:17:13 +00:00
|
|
|
|
|
|
|
if( empty($user->id) ) {
|
|
|
|
if( !empty($search_name) ){
|
|
|
|
echo "No match found. ";
|
|
|
|
if( !empty($matches) ) {
|
|
|
|
echo " Partial matches are:
|
|
|
|
<blockquote> $matches </blockquote>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo " Enter user name:
|
|
|
|
<blockquote>
|
|
|
|
<input type='text' name='search_text' >
|
|
|
|
<input type='submit' name='search_submit' value='Search'>
|
|
|
|
</form>\n";
|
|
|
|
admin_page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
row1("<b>User: </b> ".$user->name. "<br/>
|
|
|
|
Id# ". $user->id
|
2007-03-25 03:25:57 +00:00
|
|
|
. "<div align='right'>
|
2007-03-29 19:17:13 +00:00
|
|
|
<input name='reset_page' type='submit' value='Reset'>
|
2007-11-02 14:43:02 +00:00
|
|
|
<input name='manage_user' type='submit' value='Update'><br>
|
|
|
|
<input name=\"delete_user\" type=\"submit\" value=\"Delete user\">
|
|
|
|
</div>");
|
|
|
|
|
|
|
|
if($delete_problem){
|
|
|
|
echo "<font color='RED'>$delete_problem</font><br/>\n";
|
|
|
|
}
|
|
|
|
|
2007-03-25 03:25:57 +00:00
|
|
|
show_user_summary_public($user);
|
2008-01-07 23:33:48 +00:00
|
|
|
show_profile_link_ops($user);
|
2007-03-29 19:17:13 +00:00
|
|
|
if( $is_admin ) {
|
|
|
|
row2("E-mail:", "$user->email_addr");
|
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
project_user_summary($user);
|
|
|
|
end_table();
|
|
|
|
project_user_page_private($user);
|
|
|
|
|
|
|
|
echo "</form>\n";
|
|
|
|
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* Special User status:
|
|
|
|
*/
|
|
|
|
|
|
|
|
echo "\n\n<P>
|
|
|
|
<table width='100%'><tr>
|
|
|
|
<td width='50%' valign='TOP'> \n";
|
|
|
|
|
|
|
|
echo "<form name='special_user' action='$self' method=\"POST\">
|
2007-03-29 19:17:13 +00:00
|
|
|
<input type='hidden' name='userid' value='".$user->id."'> \n";
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
start_table();
|
|
|
|
row1("Special User Status: $user->name", $Nbf );
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
for($i=0;$i<$Nbf;$i++) {
|
2007-12-19 21:28:58 +00:00
|
|
|
$bit = substr($user->prefs->special_user, $i, 1);
|
2007-03-25 03:25:57 +00:00
|
|
|
echo "<tr><td><input type='checkbox'' name='special_user_".$i."' value='1'";
|
|
|
|
if ($bit == 1) {
|
|
|
|
echo " checked='checked'";
|
|
|
|
}
|
|
|
|
echo ">". $special_user_bitfield[$i] ."</td></tr>\n";
|
|
|
|
}
|
|
|
|
echo "</tr>";
|
|
|
|
|
2007-03-29 19:17:13 +00:00
|
|
|
if( $is_admin ) {
|
|
|
|
echo "</tr><td colspan=$Nbf align='RIGHT'>
|
2007-03-25 03:25:57 +00:00
|
|
|
<input name='special_user' type='SUBMIT' value='Apply'>
|
|
|
|
</td></tr>\n";
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
end_table();
|
|
|
|
echo "</form>\n";
|
|
|
|
|
|
|
|
echo "\n\n</td><td valign='TOP'>\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* Suspended posting privileges
|
|
|
|
*/
|
|
|
|
|
|
|
|
echo "<form name='banishment' action='$self' method=\"POST\">
|
2007-03-29 19:17:13 +00:00
|
|
|
<input type='hidden' name='userid' value='".$user->id."'> \n";
|
2007-03-25 03:25:57 +00:00
|
|
|
start_table();
|
|
|
|
row1("Suspension: $user->name");
|
|
|
|
|
|
|
|
if( $user->banished_until ) {
|
|
|
|
$dt = $user->banished_until - time();
|
|
|
|
if( $dt > 0 ) {
|
|
|
|
$x = " Suspended until " . time_str($user->banished_until)
|
|
|
|
."<br/> (Expires in " . time_diff($dt) .")" ;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$x = " last suspended " . time_str($user->banished_until);
|
|
|
|
}
|
|
|
|
row1($x);
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
echo "<tr><td>
|
|
|
|
Suspend user for:
|
|
|
|
<blockquote>
|
|
|
|
<input type='radio' name='suspend_for' value='3600'> 1 hour <br/>
|
|
|
|
<input type='radio' name='suspend_for' value='7200'> 2 hours <br/>
|
2007-03-29 19:17:13 +00:00
|
|
|
<input type='radio' name='suspend_for' value='18000'> 6 hours <br/>
|
|
|
|
<input type='radio' name='suspend_for' value='36000'> 12 hours <br/>
|
2007-03-25 03:25:57 +00:00
|
|
|
<input type='radio' name='suspend_for' value='86400'> 24 hours <br/>
|
2007-03-29 19:17:13 +00:00
|
|
|
";
|
|
|
|
if( $is_admin ){ // in case we are only a moderator
|
2007-03-25 03:25:57 +00:00
|
|
|
echo "
|
2007-03-29 19:17:13 +00:00
|
|
|
<input type='radio' name='suspend_for' value='172800'> 48 hours <br/>
|
2007-03-25 03:25:57 +00:00
|
|
|
<input type='radio' name='suspend_for' value='",86400*7,"'> 1 week <br/>
|
|
|
|
<input type='radio' name='suspend_for' value='",86400*14,"'> 2 weeks <br/>
|
|
|
|
";
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
if($dt>0) {
|
|
|
|
echo "
|
|
|
|
<input type='radio' name='suspend_for' value='-1'> <b>unsuspend</b> <br/>";
|
|
|
|
}
|
|
|
|
echo "
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
|
|
echo "<P>Reason (required):\n";
|
|
|
|
echo "<textarea name='suspend_reason' cols='40' rows='4'></textarea>";
|
|
|
|
echo "<br><font size='-2' >The reason will be sent to both the user
|
|
|
|
and to the project administrators.</font>\n";
|
|
|
|
|
|
|
|
|
|
|
|
echo "<p align='RIGHT'><input name='suspend_submit' type='SUBMIT' value='Apply'></P>\n";
|
|
|
|
echo " </td></tr>\n";
|
|
|
|
|
|
|
|
end_table();
|
|
|
|
echo "</form>\n";
|
|
|
|
|
|
|
|
echo "</td></tr>
|
|
|
|
</table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
if($q) {
|
|
|
|
echo "<P><font color='grey'>Query: $q </font>";
|
2007-03-29 19:17:13 +00:00
|
|
|
}
|
2007-03-25 03:25:57 +00:00
|
|
|
|
|
|
|
admin_page_tail();
|
|
|
|
|
|
|
|
$cvs_version_tracker[]= //Generated automatically - do not edit
|
|
|
|
"\$Id$";
|
|
|
|
?>
|