예제 #1
0
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) {
        $userData = erLhcoreClassModelUser::fetch((int) $_GET['user_id']);
    } elseif (isset($_GET['username']) && !empty($_GET['username'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('username' => $_GET['username'])));
    } elseif (isset($_GET['email']) && !empty($_GET['email'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('email' => $_GET['email'])));
    }
    if (!$userData instanceof erLhcoreClassModelUser) {
        throw new Exception('User could not be found!');
    }
    if ($_GET['status'] == 'true') {
        $userData->hide_online = 0;
        $text = 'flash_on';
    } else {
        $text = 'flash_off';
        $userData->hide_online = 1;
    }
    $userData->operation_admin .= "\$('#online-offline-user').text('" . $text . "');";
    erLhcoreClassUser::getSession()->update($userData);
    erLhcoreClassUserDep::setHideOnlineStatus($userData);
    erLhcoreClassRestAPIHandler::outputResponse(array('offline' => $userData->hide_online));
    erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.operator_status_changed', array('user' => &$userData, 'reason' => 'rest_api'));
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #2
0
    // dummy email value to ensure 0 res
    $param = $email != '' ? array('email' => $email) : $param;
    // init user
    $user = $user_id > 0 ? erLhcoreClassModelUser::fetch($user_id) : erLhcoreClassModelUser::findOne(array('filter' => $param));
    // check we have data
    if (!$user instanceof erLhcoreClassModelUser) {
        throw new Exception('User could not be found!');
    }
    // check if password is given, if so, validate password
    if ($password != '') {
        // check password encryption type
        if (strlen($user->password) == 40) {
            // get password hash
            $cfgSite = erConfigClassLhConfig::getInstance();
            $secretHash = $cfgSite->getSetting('site', 'secrethash');
            $pass_hash = sha1($password . $secretHash . sha1($password));
            $verified = $user->password == $pass_hash ? 1 : 0;
        } else {
            $verified = password_verify($password, $user->password) ? 1 : 0;
        }
        // set new property to user object
        $user->pass_verified = $verified;
    }
    // end of if($password != '')
    // loose password
    unset($user->password);
    erLhcoreClassRestAPIHandler::outputResponse(array('error' => false, 'result' => $user));
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #3
0
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    $chat = erLhcoreClassModelChat::fetch((int) $_GET['chat_id']);
    if (erLhcoreClassRestAPIHandler::hasAccessToRead($chat) == true) {
        erLhcoreClassRestAPIHandler::outputResponse(array('error' => false, 'messages' => erLhcoreClassChat::getPendingMessages($chat->id, isset($_GET['last_message_id']) ? (int) $_GET['last_message_id'] : 0)));
    } else {
        throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'You do not have permission to read this chat!'));
    }
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #4
0
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    $chat = erLhcoreClassModelChat::fetch((int) $_GET['chat_id']);
    if (erLhcoreClassRestAPIHandler::hasAccessToRead($chat) == true) {
        erLhcoreClassRestAPIHandler::outputResponse(array('error' => false, 'chat' => erLhcoreClassModelChat::fetch((int) $_GET['chat_id'])));
    } else {
        throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'You do not have permission to read this chat!'));
    }
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) {
        $userData = erLhcoreClassModelUser::fetch((int) $_GET['user_id']);
    } elseif (isset($_GET['username']) && !empty($_GET['username'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('username' => $_GET['username'])));
    } elseif (isset($_GET['email']) && !empty($_GET['email'])) {
        $userData = erLhcoreClassModelUser::findOne(array('filter' => array('email' => $_GET['email'])));
    }
    if (!$userData instanceof erLhcoreClassModelUser) {
        throw new Exception('User could not be found!');
    }
    if ($_GET['status'] == 'false') {
        $userData->invisible_mode = 0;
        $text = 'visibility_on';
    } else {
        $text = 'visibility_off';
        $userData->invisible_mode = 1;
    }
    $userData->operation_admin .= "\$('#vi-in-user').text('" . $text . "');";
    erLhcoreClassUser::getSession()->update($userData);
    erLhcoreClassRestAPIHandler::outputResponse(array('invisible' => $userData->invisible_mode));
    erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.operator_visibility_changed', array('user' => &$userData, 'reason' => 'rest_api'));
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #6
0
<?php

header('content-type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
erLhcoreClassRestAPIHandler::outputResponse(array('isonline' => erLhcoreClassChat::isOnline((int) $Params['user_parameters']['department_id'], true, array('online_timeout' => (int) erLhcoreClassModelChatConfig::fetch('sync_sound_settings')->data['online_timeout']))));
exit;
예제 #7
0
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    erLhcoreClassRestAPIHandler::outputResponse(erLhcoreClassRestAPIHandler::validateDepartaments());
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #8
0
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-Type: application/json');
try {
    erLhcoreClassRestAPIHandler::validateRequest();
    erLhcoreClassRestAPIHandler::outputResponse(erLhcoreClassRestAPIHandler::validateChatList());
} catch (Exception $e) {
    echo json_encode(array('error' => true, 'result' => $e->getMessage()));
}
exit;
예제 #9
0
<?php

header('content-type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
erLhcoreClassRestAPIHandler::outputResponse(array('isonline' => erLhcoreClassChat::isOnline(false, false, array('online_timeout' => (int) erLhcoreClassModelChatConfig::fetch('sync_sound_settings')->data['online_timeout']))));
exit;