function delete_user($user)
{
    global $test;
    $age = (time() - $user->create_time) / 86400;
    echo "----------------\ndeleting user {$user->id} email {$user->email_addr} name {$user->name} age {$age} days\n";
    if ($test) {
        return;
    }
    delete_profile($user);
    forum_delete_user($user);
    BoincPrivateMessage::delete_aux("userid={$user->id} or senderid={$user->id}");
    BoincNotify::delete_aux("userid={$user->id}");
    $q = "delete from user where id={$user->id}";
    _mysql_query($q);
}
Example #2
0
function do_inbox($logged_in_user)
{
    page_head(tra("Private messages") . ": " . tra("Inbox"));
    make_script();
    if (get_int("sent", true) == 1) {
        echo "<div class=\"notice\">" . tra("Your message has been sent.") . "</div>\n";
    }
    $options = get_output_options($logged_in_user);
    BoincNotify::delete_aux("userid={$logged_in_user->id} and type=" . NOTIFY_PM);
    $msgs = BoincPrivateMessage::enum("userid={$logged_in_user->id} ORDER BY date DESC");
    if (count($msgs) == 0) {
        echo tra("You have no private messages.");
    } else {
        echo "<form name=msg_list action=pm.php method=post>\n            <input type=hidden name=action value=delete_selected>\n        ";
        echo form_tokens($logged_in_user->authenticator);
        start_table();
        echo "<tr><th>" . tra("Subject") . "</th><th>" . tra("Sender and date") . "</th><th>" . tra("Message") . "</th></tr>\n";
        $i = 0;
        foreach ($msgs as $msg) {
            $sender = BoincUser::lookup_id($msg->senderid);
            if (!$sender) {
                $msg->delete();
                continue;
            }
            $i++;
            $class = $i % 2 ? "row0" : "row1";
            echo "<tr class={$class}>\n";
            $checkbox = "<input type=checkbox name=pm_select_{$msg->id}>";
            if (!$msg->opened) {
                $msg->update("opened=1");
            }
            echo "<td valign=top> {$checkbox} {$msg->subject} </td>\n";
            echo "<td valign=top>" . user_links($sender, BADGE_HEIGHT_SMALL);
            show_block_link($msg->senderid);
            echo "<br>" . time_str($msg->date) . "</td>\n";
            echo "<td valign=top>" . output_transform($msg->content, $options) . "<p>";
            $tokens = url_tokens($logged_in_user->authenticator);
            show_button("pm.php?action=new&amp;replyto={$msg->id}", tra("Reply"), tra("Reply to this message"));
            show_button("pm.php?action=delete&amp;id={$msg->id}&amp;{$tokens}", tra("Delete"), tra("Delete this message"));
            echo "</ul></td></tr>\n";
        }
        echo "\n            <tr><td>\n            <a href=\"javascript:set_all(1)\">" . tra("Select all") . "</a>\n            |\n            <a href=\"javascript:set_all(0)\">" . tra("Unselect all") . "</a>\n            </td>\n            <td colspan=2>\n            <input class=\"btn btn-danger\" type=submit value=\"" . tra("Delete selected messages") . "\">\n            </td></tr>\n        ";
        end_table();
        echo "</form>\n";
    }
    page_tail();
}
Example #3
0
function send_notify_emails()
{
    $db = BoincDb::get();
    $t = time() - (86400 + 3600);
    // 1-hour slop factor
    $query = "select notify.* from " . $db->db_name . ".notify, " . $db->db_name . ".forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > {$t}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid && strlen($message)) {
            send_notify_email($userid, $message);
            $message = "";
            $found = false;
            $i = 1;
        }
        $userid = $notify->userid;
        $x = null;
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $x = friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $x = friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $x = pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $x = subscribed_post_email_line($notify);
                break;
        }
        if ($x) {
            $message .= "{$i}) {$x}\n";
            $i++;
        } else {
            $notify->delete();
        }
    }
    if ($userid && strlen($message)) {
        send_notify_email($userid, $message);
    }
}
Example #4
0
function send_notify_emails()
{
    $t = time() - (86400 + 3600);
    // 1-hour slop factor
    $query = "select notify.* from DBNAME.notify, DBNAME.forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > {$t}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid) {
            send_notify_email($userid, $message);
            $message = "";
            $i = 1;
        }
        $userid = $notify->userid;
        $message .= "{$i}) ";
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $message .= friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $message .= friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $message .= pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $message .= subscribed_post_email_line($notify);
                break;
        }
        $message .= "\n";
        $i++;
    }
    if ($userid) {
        send_notify_email($userid, $message);
    }
}
Example #5
0
}
$userid = get_int('userid');
$auth = get_str('auth');
$since_time = time() - 30 * 86400;
$user = BoincUser::lookup_id($userid);
if (!$user) {
    xml_error();
}
// the auth in the URL includes "userid_"
//
$x = $user->id . "_" . notify_rss_auth($user);
if ($x != $auth) {
    xml_error(-155, 'Invalid authenticator');
}
$since_clause = "and create_time > {$since_time}";
$notifies = BoincNotify::enum("userid = {$userid} {$since_clause}");
$forum = news_forum();
if ($forum) {
    $threads = BoincThread::enum("forum = {$forum->id} and hidden=0 and status=0 {$since_clause}");
}
// there may be a better way to do this
$items = array();
foreach ($notifies as $n) {
    $i = null;
    $i->type = 0;
    $i->time = $n->create_time;
    $i->val = $n;
    $items[] = $i;
}
foreach ($threads as $t) {
    $i = null;
Example #6
0
            }
        }
    }
}
echo "\n    <p>\n    <form action=\"forum_thread.php\">\n    <table width=\"100%\" cellspacing=0 cellpadding=0>\n    <tr class=\"forum_toplinks\">\n    <td>\n";
$reply_url = "";
if (!$logged_in_user) {
    echo "To post messages, you must <a href=login_form.php>log in</a>.";
} else {
    if (can_reply($thread, $forum, $logged_in_user)) {
        $reply_url = "forum_reply.php?thread=" . $thread->id . "#input";
        show_button($reply_url, tra("Post to thread"), tra("Add a new message to this thread"));
    }
    if ($is_subscribed) {
        $type = NOTIFY_SUBSCRIBED_POST;
        BoincNotify::delete_aux("userid={$logged_in_user->id} and type={$type} and opaque={$thread->id}");
        $url = "forum_subscribe.php?action=unsubscribe&amp;thread=" . $thread->id . "{$tokens}";
        show_button($url, tra("Unsubscribe"), tra("You are subscribed to this thread.  Click here to unsubscribe."));
    } else {
        $url = "forum_subscribe.php?action=subscribe&amp;thread=" . $thread->id . "{$tokens}";
        show_button($url, tra("Subscribe"), tra("Click to get email when there are new posts in this thread"));
    }
    // If logged in user is moderator, enable some extra features
    //
    if (is_moderator($logged_in_user, $forum)) {
        if ($thread->hidden) {
            show_button("forum_moderate_thread_action.php?action=unhide&amp;thread=" . $thread->id . "{$tokens}", tra("Unhide"), tra("Unhide this thread"));
        } else {
            show_button("forum_moderate_thread.php?action=hide&amp;thread=" . $thread->id, tra("Hide"), tra("Hide this thread"));
        }
        if ($thread->sticky) {
Example #7
0
function handle_accepted($user)
{
    $destid = get_int('userid');
    $destuser = BoincUser::lookup_id($destid);
    if (!$destuser) {
        error_page("No such user");
    }
    $notify = BoincNotify::lookup($user->id, NOTIFY_FRIEND_ACCEPT, $destid);
    if ($notify) {
        $notify->delete();
    } else {
        echo tra("Notification not found");
    }
    page_head(tra("Friend confirmed"));
    echo tra("You are now friends with %1.", $destuser->name);
    page_tail();
}
Example #8
0
require_once "../inc/boinc_db.inc";
require_once "../inc/xml.inc";
require_once "../inc/pm.inc";
require_once "../inc/friend.inc";
require_once "../inc/notify.inc";
require_once "../project/project.inc";
$userid = get_int('userid');
$auth = get_str('auth');
$user = BoincUser::lookup_id($userid);
if (!$user) {
    xml_error();
}
if (notify_rss_auth($user) != $auth) {
    xml_error();
}
$notifies = BoincNotify::enum("userid = {$userid} order by create_time desc");
if (count($notifies)) {
    $last_mod_time = $notifies[0]->create_time;
} else {
    $last_mod_time = time();
}
$create_date = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT';
header("Expires: " . gmdate('D, d M Y H:i:s', time()) . " GMT");
header("Last-Modified: " . $create_date);
header("Content-Type: application/xml");
$description = "Community notifications";
$channel_image = URL_BASE . "rss_image.gif";
$language = "en-us";
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n    <rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n    <channel>\n    <title>" . PROJECT . "</title>\n    <link>" . URL_BASE . "</link>\n    <atom:link href=\"" . URL_BASE . "notify_rss.php\" rel=\"self\" type=\"application/rss+xml\" />\n    <description>" . $description . "</description>\n    <copyright>" . COPYRIGHT_HOLDER . "</copyright>\n    <lastBuildDate>" . $create_date . "</lastBuildDate>\n    <language>" . $language . "</language>\n    <image>\n        <url>" . $channel_image . "</url>\n        <title>" . PROJECT . "</title>\n        <link>" . URL_BASE . "</link>\n    </image>\n";
foreach ($notifies as $notify) {
    show_notify_rss_item($notify);