Exemple #1
0
 if (!IEM::isInstalled() && IEM::isInstalling() || IEM::hasUpgrade() && IEM::isUpgrading() || IEM::isCompletingUpgrade()) {
     $tempValid = true;
     break;
 }
 // Get cookie
 $tempCookie = IEM::requestGetCookie('IEM_CookieLogin', array());
 if (empty($tempCookie)) {
     break;
 }
 // Check if cookie contains user information
 if (!is_array($tempCookie) || !isset($tempCookie['user'])) {
     break;
 }
 // Get user
 $tempUser = new User_API();
 $tempUser->Load(intval($tempCookie['user']));
 // Check if the user is a valid user
 if (!isset($tempUser->settings['LoginCheck']) || !$tempUser->userid || !$tempUser->Status()) {
     break;
 }
 // Check whether or not the random number matches
 if (!$tempUser->settings['LoginCheck'] == $tempCookie['rand']) {
     break;
 }
 // The cookie is valid! Update session accordingly
 IEM::userLogin($tempUser->userid);
 $tempValid = true;
 // Check if we have login preferences
 $tempLoginPref = IEM::requestGetCookie('IEM_LoginPreference', array());
 if (is_array($tempLoginPref) && isset($tempLoginPref['takemeto'])) {
     header('Location: ' . SENDSTUDIO_APPLICATION_URL . '/admin/' . $tempLoginPref['takemeto']);
        }
        // -----


        $user = New User_API();
        $warnings = array();

        // Load existing data if editing
        if ($editMode) {
            $param_userid = IEM::ifsetor($function_params['userid'], false);
            if (!$param_userid) {
                SendResponse(false, 'userid cannot be empty.');
                exit();
            }

            $status = $user->Load($param_userid, true);
            if (!$status) {
                SendResponse(false, 'Cannot load user record.');
                exit();
            }
        }

        // ----- Check if username is available to be used
        $param_username = IEM::ifsetor($function_params['username'], false);
        if (!$param_username) {
            SendResponse(false, 'username cannot be empty.');
            exit();
        }

        $existingUser = $user->Find($param_username);