918博天堂

Server : Microsoft-IIS/10.0
System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586
User : jxgj ( 0)
PHP Version : 7.0.33
Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server
Directory :  D:/tmp_aspnet/root/5f1e4137/8eca010b/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : D:/tmp_aspnet/root/5f1e4137/8eca010b/App_Code.-mty-7id.5.cs
?#pragma checksum "D:\wwwroot\njjbjycom\wwwroot\App_Code\Utils.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "26F8AAD498D0BAE6B4FB79F8A7B17D6D4A599C98"

#line 1 "D:\wwwroot\njjbjycom\wwwroot\App_Code\Utils.cs"
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

/// <summary>
///Utils 的提要注明
/// </summary>
public class Utils
{
    /// <summary>
    /// 获得远程字符串
    /// </summary>
    public static string GetDomainStr(string uriPath)
    {
        string result = string.Empty;
        if (result == null)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            try
            {
                client.Encoding = System.Text.Encoding.UTF8;
                result = client.DownloadString(uriPath);
            }
            catch
            { result = "临时无法衔接!"; }
        }
        return result;
    }

    /// <summary>
    /// 写cookie值
    /// </summary>
    /// <param name="strName">名称</param>
    /// <param name="strValue">值</param>
    /// <param name="strValue">过期功夫(分钟)</param>
    public static void WriteCookie(string strName, string strValue, int expires)
    {
        HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
        if (cookie == null)
        {
            cookie = new HttpCookie(strName);
        }
        cookie.Value = strValue;
        cookie.Expires = DateTime.Now.AddMinutes(expires);
        HttpContext.Current.Response.AppendCookie(cookie);
    }

    /// <summary>
    /// 读cookie值
    /// </summary>
    /// <param name="strName">名称</param>
    /// <returns>cookie值</returns>
    public static string GetCookie(string strName)
    {
        if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null)
            return HttpContext.Current.Request.Cookies[strName].Value.ToString();

        return "";
    }

    /// <summary>
    /// 显示Css形状地址
    /// </summary>
    /// <param name="weburl"></param>
    /// <returns></returns>
    public static string GetStyleUrl(string weburl)
    {
        return "<link href=\"" + weburl + "Style/css.css\" rel=\"stylesheet\" type=\"text/css\" />";
    }
    public static string GetOtStyleUrl(string weburl)
    {
        return "<link href=\"" + weburl + "Style/cloud-zoom.css\" rel=\"stylesheet\" type=\"text/css\" />";
    }

    /// <summary>
    /// 将字符串转换为Int32类型
    /// </summary>
    /// <param name="expression">要转换的字符串</param>
    /// <param name="defValue">缺省值</param>
    /// <returns>转换后的int类型了局</returns>
    public static int StrToInt(string expression, int defValue)
    {
        if (string.IsNullOrEmpty(expression) || expression.Trim().Length >= 11 || !Regex.IsMatch(expression.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
            return defValue;

        int rv;
        if (Int32.TryParse(expression, out rv))
            return rv;

        return Convert.ToInt32(StrToFloat(expression, defValue));
    }

    /// <summary>
    /// string型转换为float型
    /// </summary>
    /// <param name="strValue">要转换的字符串</param>
    /// <param name="defValue">缺省值</param>
    /// <returns>转换后的int类型了局</returns>
    public static float StrToFloat(string expression, float defValue)
    {
        if ((expression == null) || (expression.Length > 10))
            return defValue;

        float intValue = defValue;
        if (expression != null)
        {
            bool IsFloat = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
            if (IsFloat)
                float.TryParse(expression, out intValue);
        }
        return intValue;
    }

    #region 获切当前绝对蹊径
    /// <summary>
    /// 获切当前绝对蹊径
    /// </summary>
    /// <param name="strPath">指定的蹊径</param>
    /// <returns>绝对蹊径</returns>
    public static string GetMapPath(string strPath)
    {
        if (strPath.ToLower().StartsWith("http://"))
        {
            return strPath;
        }
        if (HttpContext.Current != null)
        {
            return HttpContext.Current.Server.MapPath(strPath);
        }
        else //非web法式引用
        {
            strPath = strPath.Replace("/", "\\");
            if (strPath.StartsWith("\\"))
            {
                strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\');
            }
            return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
        }
    }
    #endregion

    /// <summary>
    /// 返回文件扩大名,不含“.”
    /// </summary>
    /// <param name="_filepath">文件全名称</param>
    /// <returns>string</returns>
    public static string GetFileExt(string _filepath)
    {
        if (string.IsNullOrEmpty(_filepath))
        {
            return "";
        }
        if (_filepath.LastIndexOf(".") > 0)
        {
            return _filepath.Substring(_filepath.LastIndexOf(".") + 1); //文件扩大名,不含“.”
        }
        return "";
    }

    /// <summary>
    /// 判断是否必要加水印
    /// </summary>
    /// <returns></returns>
    public static bool CheckWarter()
    { 
        UploadConfig upConfig = Paper.loadConfigUpload(System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["UploadConfigpath"].ToString()));
        if (upConfig.watermarktype != 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    /// <summary>
    /// 判断是否必要缩略图
    /// </summary>
    /// <returns></returns>
    public static bool CheckThumbnail()
    {
        UploadConfig upConfig = Paper.loadConfigUpload(System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["UploadConfigpath"].ToString()));
        if (upConfig.thumbnailwidth > 0 && upConfig.thumbnailheight > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}


#line default
#line hidden