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)) {
                foreach ($images as $img) {
                    //$html .= '<div class="image-item" id="'. $img->id .'"><img class="thumb" src="'.$img->link. '"/></div>';
                    if (!is_object($img) && !is_array($img)) {
                        continue;
                    }
                    $result[] = array('link' => $img->link, 'id' => $img->id, 'title' => $img->title, 'description' => $img->description);
                }
                $return['result'] = 'success';
                $return['data'] = $result;
            }
            //$html .= '</div>';
            hw_print_json_ajax($return);
        } elseif ($action == 'valid_session') {
            //valid token if expire then create new one
            HW_IMGUR::get_token();
            hw_print_json_ajax(array('result' => 'done', 'error' => 0, 'message' => ''));
        }
    }
}
    $pvars = array('image' => base64_encode($data));
    //$image = file_get_contents($_FILES['file']['tmp_name']);
    $args = array('name' => $name, 'title' => $name);
    $reply = HW_IMGUR::upload_image2album(base64_encode($data), HW_IMGUR::main_album, $args);
    /*
    	$client_id = "9b5122a3d34e478";
    	$ch = curl_init();
    	curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
    	curl_setopt($ch, CURLOPT_POST, TRUE);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    	curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $client_id ));
    	curl_setopt($ch, CURLOPT_POSTFIELDS, $pvars );
    	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    	curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    
    	$reply = curl_exec($ch);
    	curl_close($ch);
    
    	$reply = json_decode($reply);*/
    if (empty($reply->error)) {
        $return_json['result'] = 'success';
        $return_json['link'] = $reply->data->link;
        $return_json['title'] = $name;
    } else {
        $return_json = $reply;
    }
    hw_print_json_ajax($return_json);
    //printf('<img height="180" src="%s" >', $newimgurl);
    exit;
}