Example #1
0
                   "\n\n$verify_url\n\n".
                   wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody2"],72);
                phorum_email_user(array($user["email"]), $maildata);

                $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["RegVerifyEmail"];
                $template="message";

            // The user is active.
            } else {

                // Generate and store a new password for the user.
                include_once( "./include/profile_functions.php" );
                $newpass = phorum_gen_password();
                $tmp_user["user_id"] = $uid;
                $tmp_user["password_temp"] = $newpass;
                phorum_user_save($tmp_user);

                // Mail the new password.
                $user = phorum_user_get( $uid );
                $maildata = array();
                $maildata['mailmessage'] =
                   wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody1"],72).
                   "\n\n".
                   $PHORUM["DATA"]["LANG"]["Username"] .": $user[username]\n".
                   $PHORUM["DATA"]["LANG"]["Password"] .": $newpass".
                   "\n\n".
                   wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody2"],72);
                $maildata['mailsubject'] = $PHORUM["DATA"]["LANG"]["LostPassEmailSubject"];
                phorum_email_user(array( 0 => $user['email'] ), $maildata);

                $okmsg = $PHORUM["DATA"]["LANG"]["LostPassSent"];
Example #2
0
    if(is_array($user_data_old) && count($user_data_old)) {
        foreach($user_data_old as $old_key => $old_val) {
            $type=-1;
            // find out which ID that custom-field has
            foreach($PHORUM['PROFILE_FIELDS'] as $ctype => $cdata) {
                if($cdata['name'] == $old_key) {
                    $type=$ctype;
                    break;
                }
            }

            if($type != -1) { // store it only if we found it
                if( $old_val!=="" ) {
                    if(!is_array($old_val)) {
                        $user_data_new[$type] = substr($old_val,0,$PHORUM['PROFILE_FIELDS'][$type]['length']);
                    } else {
                        $user_data_new[$type] = $old_val;
                    }
                }
            }
        }
    }
    
    $userdata['user_data']=$user_data_new;
    phorum_user_save($userdata);
}
// remove old column
//mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} DROP newflags",$cid);

?>
Example #3
0
/**
 * A common function which is used to save the userdata from the post-data.
 * @param panel - The panel for which to save data.
 * @return array - An array containing $error and $okmsg.
 */
function phorum_controlcenter_user_save($panel)
{
    $PHORUM = $GLOBALS['PHORUM'];
    $error = "";
    $okmsg = "";

    // Setup the default userdata fields that may be changed
    // from the control panel interface.
    $userdata = array(
        'signature'       => NULL,
        'hide_email'      => NULL,
        'hide_activity'   => NULL,
        'password'        => NULL,
        'tz_offset'       => NULL,
        'is_dst'          => NULL,
        'user_language'   => NULL,
        'threaded_list'   => NULL,
        'threaded_read'   => NULL,
        'email_notify'    => NULL,
        'show_signature'  => NULL,
        'pm_email_notify' => NULL,
        'email'           => NULL,
        'email_temp'      => NULL,
        'user_template'   => NULL,
        'moderation_email'=> NULL,
    );
    // Add custom profile fields as acceptable fields.
    foreach ($PHORUM["PROFILE_FIELDS"] as $field) {
        $userdata[$field["name"]] = NULL;
    }
    // Update userdata with $_POST information.
    foreach ($_POST as $key => $val) {
       if (array_key_exists($key, $userdata)) {
           $userdata[$key] = $val;
       }
    }
    // Remove unused profile fields.
    foreach ($userdata as $key => $val) {
        if (is_null($val)) {
            unset($userdata[$key]);
        }
    }

    // Set static userdata.
    $userdata["user_id"] = $PHORUM["user"]["user_id"];
    $userdata["fk_campsite_user_id"] = $PHORUM["user"]["fk_campsite_user_id"];

    // Run a hook, so module writers can update and check the userdata.
    $userdata = phorum_hook("cc_save_user", $userdata);

    // Set $error, in case the before_register hook did set an error.
    if (isset($userdata['error'])) {
        $error=$userdata['error'];
        unset($userdata['error']);
    // Try to update the userdata in the database.
    } elseif (!phorum_user_save($userdata)) {
        // Updating the user failed.
        $error = $PHORUM["DATA"]["LANG"]["ErrUserAddUpdate"];
    } else {
	// Sync the campsite user
	require_once('../../admin-files/localizer/Localizer.php');
	require_once('../../classes/User.php');
	$campsiteUser = new User($userdata["fk_campsite_user_id"]);
	if ($campsiteUser->exists()) {
		if (array_key_exists('password', $userdata)) {
			$campsiteUser->setPassword($userdata["password"]);
		} elseif (array_key_exists('email', $userdata)) {
			$campsiteUser->setProperty('EMail', $userdata["email"]);
		}
	}

        // Updating the user was successful.
        $okmsg = $PHORUM["DATA"]["LANG"]["ProfileUpdatedOk"];

        // Let the userdata be reloaded.
        phorum_user_set_current_user($userdata["user_id"]);

        // If a new password was set, let's create a new session.
        if (isset($userdata["password"]) && !empty($userdata["password"])) {
            phorum_user_create_session();
        }

        // Copy data from the updated user back into the template data.
        // Leave PANEL and forum_id alone (these are injected into the
        // userdata in the template from this script).
        foreach ($GLOBALS["PHORUM"]["DATA"]["PROFILE"] as $key => $val) {
            if ($key == "PANEL" || $key == "forum_id") continue;
            if (isset($GLOBALS["PHORUM"]["user"][$key])) {
                $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = $GLOBALS["PHORUM"]["user"][$key];
            } else {
                $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = "";
            }
        }
    }

    return array($error, $okmsg);
}
Example #4
0
function phorum_user_check_login( $username, $password )
{
    $ret = false;
    $temp_check = false;

    $user_id = phorum_db_user_check_pass( $username, sha1( $password ) );
    // regular password failed, try the temp password
    if ( $user_id == 0 ) {
        $user_id = phorum_db_user_check_pass( $username, sha1( $password ), true );
        $temp_check = true;
    }

    if ( $user_id > 0 ) {
        // if this was a temp password, set the normal pass to the temp password
        // do this before we get the user so the data is up to date.
        // leave the temp password alone as setting to empty is bad.
        if ( $temp_check ) {
            $tmp_user["user_id"] = $user_id;
            $tmp_user["password"] = $password;
            phorum_user_save( $tmp_user );
        }

        $ret = phorum_user_set_current_user( $user_id );
    }

    return $ret;
}
Example #5
0
function phorum_htmlpurifier_migrate_sigs($offset)
{
    global $PHORUM;
    if (!$offset) {
        return;
    }
    // bail out quick of $offset == 0
    @set_time_limit(0);
    // attempt to let this run
    $increment = $PHORUM['mod_htmlpurifier']['migrate-sigs-increment'];
    require_once dirname(__FILE__) . '/../migrate.php';
    // migrate signatures
    // do this in batches so we don't run out of time/space
    $end = $offset + $increment;
    $user_ids = array();
    for ($i = $offset; $i < $end; $i++) {
        $user_ids[] = $i;
    }
    $userinfos = phorum_db_user_get_fields($user_ids, 'signature');
    foreach ($userinfos as $i => $user) {
        if (empty($user['signature'])) {
            continue;
        }
        $sig = $user['signature'];
        // perform standard Phorum processing on the sig
        $sig = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $sig);
        $sig = preg_replace("/<((http|https|ftp):\\/\\/[a-z0-9;\\/\\?:@=\\&\$\\-_\\.\\+!*'\\(\\),~%]+?)>/i", "\$1", $sig);
        // prepare fake data to pass to migration function
        $fake_data = array(array("author" => "", "email" => "", "subject" => "", 'body' => $sig));
        list($fake_message) = phorum_htmlpurifier_migrate($fake_data);
        $user['signature'] = $fake_message['body'];
        if (!phorum_user_save($user)) {
            exit('Error while saving user data');
        }
    }
    unset($userinfos);
    // free up memory
    // query for highest ID in database
    $type = $PHORUM['DBCONFIG']['type'];
    if ($type == 'mysql') {
        $conn = phorum_db_mysql_connect();
        $sql = "select MAX(user_id) from {$PHORUM['user_table']}";
        $res = mysql_query($sql, $conn);
        $row = mysql_fetch_row($res);
        $top_id = (int) $row[0];
    } elseif ($type == 'mysqli') {
        $conn = phorum_db_mysqli_connect();
        $sql = "select MAX(user_id) from {$PHORUM['user_table']}";
        $res = mysqli_query($conn, $sql);
        $row = mysqli_fetch_row($res);
        $top_id = (int) $row[0];
    } else {
        exit('Unrecognized database!');
    }
    $offset += $increment;
    if ($offset > $top_id) {
        // test for end condition
        echo 'Migration finished';
        $PHORUM['mod_htmlpurifier']['migrate-sigs'] = false;
        phorum_htmlpurifier_commit_settings();
        return true;
    }
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = 'admin.php?module=modsettings&mod=htmlpurifier&migrate-sigs=' . $offset;
    // relies on output buffering to work
    header("Location: http://{$host}{$uri}/{$extra}");
    exit;
}
Example #6
0
        	$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["RegVerifyMod"];
        // The user is waiting for email and/or email+moderator confirmation.
        } else {
            // Waiting for both? Then switch to wait for moderator.
            if ($user["active"] == PHORUM_USER_PENDING_BOTH) {
                $moduser["active"] = PHORUM_USER_PENDING_MOD;
                $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["RegVerifyMod"];
            // Only email confirmation was required. Active the user.
            } else {
                $moduser["active"] = PHORUM_USER_ACTIVE;
                $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["RegAcctActive"];
            }

            // Save the new user active status.
            $moduser["user_id"] = $user_id;
            phorum_user_save($moduser);
        }

    // Validation code incorrect.
    } else {
        $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["RegVerifyFailed"];
    }

    include phorum_get_template("header");
    phorum_hook("after_header");
    include phorum_get_template("message");
    phorum_hook("before_footer");
    include phorum_get_template("footer");
    return;

}