public function req_is($type){

        switch(strtolower($type)){
            case 'ajax':
                return (
                    (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'))       ||
                    (isset($_SERVER["CONTENT_TYPE"]) && stripos($_SERVER["CONTENT_TYPE"],'application/json')!==false)           ||
                    (isset($_SERVER["HTTP_CONTENT_TYPE"]) && stripos($_SERVER["HTTP_CONTENT_TYPE"],'application/json')!==false)
                );
                break;

            case 'mobile':

                $mobileDevices = [
                    'midp','240x320','blackberry','netfront','nokia','panasonic','portalmmm','sharp','sie-','sonyericsson',
                    'symbian','windows ce','benq','mda','mot-','opera mini','philips','pocket pc','sagem','samsung',
                    'sda','sgh-','vodafone','xda','iphone', 'ipod','android'
                ];

                return preg_match('/(' . implode('|', $mobileDevices). ')/i',strtolower($_SERVER['HTTP_USER_AGENT']));
                break;

            case 'post':
                return (strtolower($_SERVER['REQUEST_METHOD']) == 'post');
                break;

            case 'get':
                return (strtolower($_SERVER['REQUEST_METHOD']) == 'get');
                break;

            case 'put':
                return (strtolower($_SERVER['REQUEST_METHOD']) == 'put');
                break;

            case 'delete':
                return (strtolower($_SERVER['REQUEST_METHOD']) == 'delete');
                break;

            case 'ssl':
                return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
                break;
        }

        return false;
    }