Example #1
0
function del_user_dir($edogyt44 = 0)
{
	$vomawoh8 = (create_user_dir(0, 2) === true);
	if (!$vomawoh8) {
		GetFlashMessages();
	}
	if (!is_array($edogyt44) && $edogyt44 > 0) {
		remove_directory(TEMP_DIRECTORY . "/user/" . $edogyt44);
	}
	return true;
}
Example #2
0
    /**
     * Create
     * This function creates a user based on the current class vars and then save permissions once it has a new userid from the database.
     *
     * @return False|Int Returns false if it couldn't create a user, otherwise returns the new userid.
     */
    function Create() {
        if (!ss9024kwehbehb($this)) {
            return -1;
        }

        $this->FilterData();

        if (!$this->Validate('create')) {
            return false;
        }

        $processed_unique_token = API_USERS::generateUniqueToken(SENDSTUDIO_LICENSEKEY . $this->username);
        $processed_password = API_USERS::generatePasswordHash($this->password, $processed_unique_token);

        if (!is_array($this->eventactivitytype)) {
            $this->eventactivitytype = array();
        }

        if ($this->trialuser == '1') {
            $agency_variables = get_agency_license_variables();

            $this->admintype = 'c';
        }

        $query = "
			INSERT INTO [|PREFIX|]users (
				groupid, username, password, unique_token, status, emailaddress, fullname,
				trialuser, admintype, listadmintype, templateadmintype, segmentadmintype,
				editownsettings, usertimezone,
				textfooter, htmlfooter,
				infotips,
				smtpserver, smtpusername, smtppassword, smtpport,
				createdate, lastloggedin,
				enableactivitylog, usewysiwyg, xmlapi, xmltoken,
				gettingstarted, googlecalendarusername, googlecalendarpassword,
				eventactivitytype,
				adminnotify_email, adminnotify_send_flag, adminnotify_send_threshold,
				adminnotify_send_emailtext, adminnotify_import_flag, adminnotify_import_threshold, adminnotify_import_emailtext
			) VALUES (
				" . intval($this->groupid) . ", '" . $this->Db->Quote($this->username) . "', '" . $this->Db->Quote($processed_password) . "', '" . $this->Db->Quote($processed_unique_token) . "', '" . intval($this->status) . "', '" . $this->Db->Quote($this->emailaddress) . "', '" . $this->Db->Quote($this->fullname) . "',
				'" . ($this->trialuser == '1' ? '1' : '0') . "', '" . $this->Db->Quote($this->admintype) . "', '" . $this->Db->Quote($this->listadmintype) . "', '" . $this->Db->Quote($this->templateadmintype) . "', '" . $this->Db->Quote($this->segmentadmintype) . "',
				'" . intval($this->editownsettings) . "', '" . $this->Db->Quote($this->usertimezone) . "',
				'" . $this->Db->Quote($this->textfooter) . "', '" . $this->Db->Quote($this->htmlfooter) . "',
				'" . intval($this->infotips) . "',
				'" . $this->Db->Quote($this->smtpserver) . "', '" . $this->Db->Quote($this->smtpusername) . "', '" . $this->Db->Quote(base64_encode($this->smtppassword)) . "', " . intval($this->smtpport) . ",
				" . time() . ", 0,
				'" . intval($this->enableactivitylog) . "', '" . intval($this->usewysiwyg) . "', '" . intval($this->xmlapi) . "', '" . $this->Db->Quote($this->xmltoken) . "'
				," . intval($this->gettingstarted) . ", '" . $this->Db->Quote($this->googlecalendarusername) . "', '" . $this->Db->Quote($this->googlecalendarpassword) . "', '" . serialize($this->eventactivitytype) . "',
				'" . $this->Db->Quote($this->adminnotify_email) . "', '" . intval($this->adminnotify_send_flag) . "', '" . intval($this->adminnotify_send_threshold) . "', '" . $this->Db->Quote($this->adminnotify_send_emailtext) . "',
				'" . intval($this->adminnotify_import_flag) . "', '" . intval($this->adminnotify_import_threshold) . "', '" . $this->Db->Quote($this->adminnotify_import_emailtext) . "'
			)
		";

        // We want to get the userid once it is created.
        if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') {
            $query .= ' RETURNING userid';
        }

        $this->Db->StartTransaction();
        $result = $this->Db->Query($query);

        if (!$result) {
            $this->Db->CommitTransaction();
            return false;
        }

        if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') {
            $userid = $this->Db->FetchOne($result, 'userid');
        } else {
            $userid = $this->Db->LastId(SENDSTUDIO_TABLEPREFIX . 'users_sequence');
        }

        $this->userid = $userid;

        $status = (create_user_dir($userid) === true);

        if (!$status) {
            $this->Db->RollbackTransaction();
            return false;
        }

        $this->Db->CommitTransaction();
        $this->_cacheUserTypeCount = false;
        return $userid;
    }