$nonce = isset($_POST['_nonce']) ? $_POST['_nonce'] : '';
//nonce string
//return json data
$return = array();
//valid action token
if (!NonceUtil::check($action, $nonce)) {
    $return['error'] = '1';
    $return['result'] = 'invalid token';
    $return['message'] = '[invalid token] Phiên làm việc đã hết, lưu bài viết và nạp lại trang để có thể sử dụng tính năng.';
    hw_print_json_ajax($return);
    exit;
}
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    if (hw_allow_referer()) {
        //authorize to get token
        HW_IMGUR::init();
        /**
         * load images in album
         */
        if ($action == 'load_images') {
            $album = isset($_POST['al']) ? $_POST['al'] : 'bld18';
            //or get default album
            $images = HW_IMGUR::get_images_album($album);
            $result = array();
            //$html = '<div class="album-images">';
            //catch error if imgur token expire
            if (isset($images->error)) {
                $return['result'] = 'error';
                $return['error'] = 1;
                $return['message'] = $images->message;
            } elseif (is_array($images)) {