Example #1
0
function delete_user($user)
{
    if (!empty($user->teamid)) {
        user_quit_team($user);
    }
    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}");
    }
    if ($user->total_credit > 0.0) {
        error_page("Cannot delete user: User has credit.");
        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) {
        error_page("Cannot delete user: User has {$c->count} results in the database.");
    }
    // Don't delete user if they have posted to the forums
    //
    $q = "SELECT COUNT(*) AS count FROM post WHERE user="******"Cannot delete user: User has {$c->count} forum posts.");
    }
    $q = "DELETE FROM user WHERE id=" . $user->id;
    $result = mysql_query($q);
}
Example #2
0
function delete_profile($user)
{
    $result = BoincProfile::delete_aux("userid = {$user->id}");
    if (!$result) {
        error_page("couldn't delete profile - please try again later");
    }
    delete_user_pictures($user->id);
    page_head("Delete Confirmation");
    $user->update("has_profile=0");
    echo "Your profile has been deleted<br />";
    page_tail();
}
Example #3
0
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="******"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);
}
// 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/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
require_once "../inc/profile.inc";
$user = get_logged_in_user();
$cmd = get_str("cmd", true);
if ($cmd == "delete") {
    $result = delete_profile($user);
    if (!$result) {
        error_page(tra("couldn't delete profile - please try again later"));
    }
    delete_user_pictures($user->id);
    page_head(tra("Delete Confirmation"));
    $user->update("has_profile=0");
    echo tra("Your profile has been deleted.") . "<br>";
    page_tail();
    exit;
}
page_head(tra("Profile delete confirmation"));
echo "\n    <h2>" . tra("Are you sure?") . "</h2><p>\n    " . tra("Deleted profiles are gone forever and cannot be recovered --\nyou will have to start from scratch\nif you want another profile in the future.") . "\n    <p>\n    " . tra("If you're sure, click 'Yes'\nto remove your profile from our database.") . "\n    <p>\n";
show_button("delete_profile.php?cmd=delete", tra("Yes"), tra("Delete my profile"));
show_button("index.php", tra("No"), tra("Do not delete my profile"));
page_tail();
Example #5
0
function process_create_profile($user, $profile)
{
    global $config;
    $response1 = post_str('response1', true);
    $response2 = post_str('response2', true);
    $language = post_str('language', true);
    $privatekey = parse_config($config, "<recaptcha_private_key>");
    if ($privatekey) {
        $recaptcha = new ReCaptcha($privatekey);
        $resp = $recaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
        if (!$resp->success) {
            $profile->response1 = $response1;
            $profile->response2 = $response2;
            show_profile_form($profile, tra("Your ReCaptcha response was not correct.  Please try again."));
            return;
        }
    }
    if (!akismet_check($user, $response1)) {
        $profile->response1 = $response1;
        $profile->response2 = $response2;
        show_profile_form($profile, tra("Your first response was flagged as spam by the Akismet anti-spam system.  Please modify your text and try again."));
        return;
    }
    if (!akismet_check($user, $response2)) {
        $profile->response1 = $response1;
        $profile->response2 = $response2;
        show_profile_form($profile, tra("Your second response was flagged as spam by the Akismet anti-spam system.  Please modify your text and try again."));
        return;
    }
    if (isset($_POST['delete_pic'])) {
        $delete_pic = $_POST['delete_pic'];
    } else {
        $delete_pic = "off";
    }
    if (strlen($response1) == 0 && strlen($response2) == 0 && $delete_pic != "on" && !is_uploaded_file($_FILES['picture']['tmp_name'])) {
        error_page(tra("Your profile submission was empty."));
        exit;
    }
    if ($delete_pic == "on") {
        delete_user_pictures($profile->userid);
        $profile->has_picture = false;
        $profile->verification = 0;
    }
    $profile ? $has_picture = $profile->has_picture : ($has_picture = false);
    if (is_uploaded_file($_FILES['picture']['tmp_name'])) {
        $has_picture = true;
        if ($profile) {
            $profile->verification = 0;
        }
        // echo "<br>Name: " . $_FILES['picture']['name'];
        // echo "<br>Type: " . $_FILES['picture']['type'];
        // echo "<br>Size: " . $_FILES['picture']['size'];
        // echo "<br>Temp name: " . $_FILES['picture']['tmp_name'];
        $images = getImages($_FILES['picture']['tmp_name']);
        // Write the original image file to disk.
        // TODO: define a constant for image quality.
        ImageJPEG($images[0], IMAGE_PATH . $user->id . '.jpg');
        ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg');
    }
    $response1 = sanitize_html($response1);
    $response2 = sanitize_html($response2);
    $has_picture = $has_picture ? 1 : 0;
    if ($profile) {
        $query = " response1 = '" . BoincDb::escape_string($response1) . "'," . " response2 = '" . BoincDb::escape_string($response2) . "'," . " language = '" . BoincDb::escape_string($language) . "'," . " has_picture = {$has_picture}," . " verification = {$profile->verification}" . " WHERE userid = {$user->id}";
        $result = BoincProfile::update_aux($query);
        if (!$result) {
            error_page(tra("Could not update the profile: database error"));
        }
    } else {
        $query = 'SET ' . " userid={$user->id}," . " language = '" . BoincDb::escape_string($language) . "'," . " response1 = '" . BoincDb::escape_string($response1) . "'," . " response2 = '" . BoincDb::escape_string($response2) . "'," . " has_picture = {$has_picture}," . " recommend=0, " . " reject=0, " . " posts=0, " . " uotd_time=0, " . " verification=0";
        $result = BoincProfile::insert($query);
        if (!$result) {
            error_page(tra("Could not create the profile: database error"));
        }
    }
    $user->update("has_profile=1");
    page_head(tra("Profile saved"));
    echo tra("Congratulations! Your profile was successfully entered into our database.") . "<br><br>" . "<a href=\"view_profile.php?userid=" . $user->id . "\">" . tra("View your profile") . "</a><br>";
    page_tail();
}