Exemplo n.º 1
0
 /// <summary>
 /// 序列化配置信息为XML
 /// </summary>
 /// <param name="configinfo">配置信息</param>
 /// <param name="configFilePath">配置文件完整路径</param>
 public static GeneralConfigInfo Serialiaze(GeneralConfigInfo configinfo, string configFilePath)
 {
     lock(lockHelper)
     {
         SerializationHelper.Save(configinfo, configFilePath);
     }
     return configinfo;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 静态构造函数初始化相应实例和定时器
        /// </summary>
        static GeneralConfigs()
        {
            m_configinfo = GeneralConfigFileManager.LoadConfig();

            generalConfigTimer.AutoReset = true;
            generalConfigTimer.Enabled = true;
            generalConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
            generalConfigTimer.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化文件修改时间和对象实例
        /// </summary>
        static GeneralConfigFileManager()
        {
            m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);

            try
            {
                m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
            }
            catch
            {
                if (File.Exists(ConfigFilePath))
                {
                    ReviseConfig();
                    m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     m_configinfo = GeneralConfigFileManager.LoadConfig();
 }
Exemplo n.º 5
0
Arquivo: WebUtils.cs Projeto: pcstx/OA
        /// <summary>
        /// �����ϴ����ļ�
        /// </summary>
        /// <param name="forumid">���id</param>
        /// <param name="MaxAllowFileCount">���������ϴ��ļ�����</param>
        /// <param name="MaxSizePerDay">ÿ������ĸ�����С����</param>
        /// <param name="MaxFileSize">�������������ļ��ֽ���</param>/// 
        /// <param name="TodayUploadedSize">�����Ѿ��ϴ��ĸ����ֽ�����</param>
        /// <param name="AllowFileType">������ļ�����, ��string[]��ʽ�ṩ</param>
        /// <param name="config">�������淽ʽ 0=����/��/�մ��벻ͬĿ¼ 1=����/��/��/��̳���벻ͬĿ¼ 2=����̳���벻ͬĿ¼ 3=���ļ����ʹ��벻ͬĿ¼</param>
        /// <param name="watermarkstatus">ͼƬˮӡλ��</param>
        /// <param name="filekey">File�ؼ���Key(��Name����)</param>
        /// <returns>�ļ���Ϣ�ṹ</returns>
        public static AttachmentInfo[] SaveRequestFiles(int forumid, int MaxAllowFileCount, int MaxSizePerDay, int MaxFileSize, int TodayUploadedSize, string AllowFileType, int watermarkstatus, GeneralConfigInfo config, string filekey)
        {
            string[] tmp = Utils.SplitString(AllowFileType, "\r\n");
            string[] AllowFileExtName = new string[tmp.Length];
            int[] MaxSize = new int[tmp.Length];

            for (int i = 0; i < tmp.Length; i++)
            {
                AllowFileExtName[i] = Utils.CutString(tmp[i],0, tmp[i].LastIndexOf(","));
                MaxSize[i] = Utils.StrToInt(Utils.CutString(tmp[i], tmp[i].LastIndexOf(",") + 1), 0);
            }

            int saveFileCount = 0;

            int fCount = HttpContext.Current.Request.Files.Count;

            for (int i = 0; i < fCount; i++)
            {
                if (!HttpContext.Current.Request.Files[i].FileName.Equals("") && HttpContext.Current.Request.Files.AllKeys[i].Equals(filekey))
                {
                    saveFileCount++;
                }
            }

            AttachmentInfo[] attachmentinfo = new AttachmentInfo[saveFileCount];
            if (saveFileCount > MaxAllowFileCount)
                return attachmentinfo;

            saveFileCount = 0;

            Random random = new Random(unchecked((int)DateTime.Now.Ticks));

            for (int i = 0; i < fCount; i++)
            {
                if (!HttpContext.Current.Request.Files[i].FileName.Equals("") && HttpContext.Current.Request.Files.AllKeys[i].Equals(filekey))
                {
                    string filename = Path.GetFileName(HttpContext.Current.Request.Files[i].FileName);
                    string fileextname = Utils.CutString(filename, filename.LastIndexOf(".") + 1).ToLower();
                    string filetype = HttpContext.Current.Request.Files[i].ContentType.ToLower();
                    int filesize = HttpContext.Current.Request.Files[i].ContentLength;
                    string newfilename = "";

                    attachmentinfo[saveFileCount] = new AttachmentInfo();

                    attachmentinfo[saveFileCount].Sys_noupload = "";

                    // �ж� �ļ���չ��/�ļ���С/�ļ����� �Ƿ����Ҫ��
                    if (!(Utils.IsImgFilename(filename) && !filetype.StartsWith("image")))
                    {
                        int extnameid = Utils.GetInArrayID(fileextname, AllowFileExtName);

                        if (extnameid >= 0 && (filesize <= MaxSize[extnameid]) && (MaxFileSize >= filesize /*|| MaxAllSize == 0*/) && (MaxSizePerDay - TodayUploadedSize >= filesize))
                        {
                            TodayUploadedSize = TodayUploadedSize + filesize;
                            string UploadDir = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/");
                            StringBuilder savedir = new StringBuilder("");
                            //�������淽ʽ 0=����/��/�մ��벻ͬĿ¼ 1=����/��/��/��̳���벻ͬĿ¼ 2=����̳���벻ͬĿ¼ 3=���ļ����ʹ��벻ͬĿ¼
                            if (config.Attachsave == 1)
                            {
                                savedir.Append(DateTime.Now.ToString("yyyy"));
                                savedir.Append(Path.DirectorySeparatorChar);
                                savedir.Append(DateTime.Now.ToString("MM"));
                                savedir.Append(Path.DirectorySeparatorChar);
                                savedir.Append(DateTime.Now.ToString("dd"));
                                savedir.Append(Path.DirectorySeparatorChar);
                                savedir.Append(forumid.ToString());
                                savedir.Append(Path.DirectorySeparatorChar);
                            }
                            else if (config.Attachsave == 2)
                            {
                                savedir.Append(forumid);
                                savedir.Append(Path.DirectorySeparatorChar);
                            }
                            else if (config.Attachsave == 3)
                            {
                                savedir.Append(fileextname);
                                savedir.Append(Path.DirectorySeparatorChar);
                            }
                            else
                            {
                                savedir.Append(DateTime.Now.ToString("yyyy"));
                                savedir.Append(Path.DirectorySeparatorChar);
                                savedir.Append(DateTime.Now.ToString("MM"));
                                savedir.Append(Path.DirectorySeparatorChar);
                                savedir.Append(DateTime.Now.ToString("dd"));
                                savedir.Append(Path.DirectorySeparatorChar);
                            }
                            // ���ָ��Ŀ¼����������
                            if (!Directory.Exists(UploadDir + savedir.ToString()))
                            {
                                Utils.CreateDir(UploadDir + savedir.ToString());
                            }

                            newfilename = savedir.ToString() + (Environment.TickCount & int.MaxValue).ToString() +  i.ToString() + random.Next(1000,9999).ToString() + "." + fileextname;

                            try
                            {
                                // �����bmp jpg pngͼƬ����
                                if ((fileextname == "bmp" || fileextname == "jpg" || fileextname == "jpeg" || fileextname == "png") && filetype.StartsWith("image"))
                                {

                                    Image img = Image.FromStream(HttpContext.Current.Request.Files[i].InputStream);
                                    if (config.Attachimgmaxwidth > 0 && img.Width > config.Attachimgmaxwidth)
                                    {
                                        attachmentinfo[saveFileCount].Sys_noupload = "ͼƬ���Ϊ" + img.Width.ToString() + ", ϵͳ����������Ϊ" + config.Attachimgmaxwidth.ToString();

                                    }
                                    if (config.Attachimgmaxheight > 0 && img.Height > config.Attachimgmaxheight)
                                    {
                                        attachmentinfo[saveFileCount].Sys_noupload = "ͼƬ�߶�Ϊ" + img.Width.ToString() + ", ϵͳ��������߶�Ϊ" + config.Attachimgmaxheight.ToString();
                                    }
                                    if (attachmentinfo[saveFileCount].Sys_noupload == "")
                                    {
                                        if (watermarkstatus == 0)
                                        {
                                            HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newfilename);
                                            attachmentinfo[saveFileCount].Filesize = filesize;
                                        }
                                        else
                                        {
                                            if (config.Watermarktype == 1 && File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "watermark/" + config.Watermarkpic)))
                                            {
                                                AddImageSignPic(img, UploadDir + newfilename, Utils.GetMapPath(BaseConfigs.GetForumPath + "watermark/" + config.Watermarkpic), config.Watermarkstatus, config.Attachimgquality, config.Watermarktransparency);
                                            }
                                            else
                                            {
                                                string watermarkText;
                                                watermarkText = config.Watermarktext.Replace("{1}", config.Forumtitle);
                                                watermarkText = watermarkText.Replace("{2}", "http://" + DNTRequest.GetCurrentFullHost() + "/");
                                                watermarkText = watermarkText.Replace("{3}", Utils.GetDate());
                                                watermarkText = watermarkText.Replace("{4}", Utils.GetTime());
                                                AddImageSignText(img, UploadDir + newfilename, watermarkText, config.Watermarkstatus, config.Attachimgquality, config.Watermarkfontname, config.Watermarkfontsize);
                                            }
                                            // ��ü�ˮӡ����ļ�����
                                            attachmentinfo[saveFileCount].Filesize = new FileInfo(UploadDir + newfilename).Length;
                                        }
                                    }
                                }
                                else
                                {
                                    HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newfilename);
                                    attachmentinfo[saveFileCount].Filesize = filesize;
                                }
                            }
                            catch
                            {
                                if (!(Utils.FileExists(UploadDir + newfilename)))
                                {
                                    HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newfilename);
                                    attachmentinfo[saveFileCount].Filesize = filesize;
                                }
                            }

                            try
                            {
                                //�����ļ�Ԥ����ָ������
                                IPreview preview = PreviewProvider.GetInstance(fileextname.Trim());
                                if (preview != null)
                                    preview.OnSaved(UploadDir + newfilename);
                            }
                            catch
                            {}

                        }
                        else
                        {
                            if (extnameid < 0)
                            {
                                attachmentinfo[saveFileCount].Sys_noupload = "�ļ���ʽ��Ч";
                            }
                            else if (MaxSizePerDay - TodayUploadedSize < filesize)
                            {
                                attachmentinfo[saveFileCount].Sys_noupload = "�ļ����ڽ��������ϴ����ֽ���";
                            }
                            else if (filesize > MaxSize[extnameid])
                            {
                                attachmentinfo[saveFileCount].Sys_noupload = "�ļ����ڸ����͸���������ֽ���";
                            }
                            else
                            {
                                attachmentinfo[saveFileCount].Sys_noupload = "�ļ����ڵ����ļ������ϴ����ֽ���";
                            }
                        }
                    }
                    else
                    {
                        attachmentinfo[saveFileCount].Sys_noupload = "�ļ���ʽ��Ч";
                    }
                    attachmentinfo[saveFileCount].Filename = newfilename;
                    attachmentinfo[saveFileCount].Description = fileextname;
                    attachmentinfo[saveFileCount].Filetype = filetype;
                    attachmentinfo[saveFileCount].Attachment = filename;
                    attachmentinfo[saveFileCount].Downloads = 0;
                    attachmentinfo[saveFileCount].Postdatetime = DateTime.Now.ToString();
                    attachmentinfo[saveFileCount].Sys_index = i;
                    saveFileCount++;
                }
            }
            return attachmentinfo;
        }
Exemplo n.º 6
0
Arquivo: BasePage.cs Projeto: pcstx/OA
            ClientScript.RegisterStartupScript(this.GetType(), key, scriptstr);
#endif
        }

        /// <summary>
        /// 检查cookie是否有效
        /// </summary>
        /// <returns></returns>
        public bool CheckCookie()
        {
            config = GeneralConfigs.GetConfig();

            // 如果IP访问列表有设置则进行判断
            if (config.Adminipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n");
                if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    Context.Response.Redirect(BaseConfigs.GetForumPath + "aspx/login.aspx");
                    return false;
Exemplo n.º 7
0
Arquivo: BasePage.cs Projeto: pcstx/OA
		/// <summary>
		/// BasePage类构造函数
		/// </summary>
		public BasePage()
		{
            strButtonHideScript = "<script type=\"text/javascript\"  lanuage=\"javascript\"> \r\n" +
                        "buttonHidesuccess(); \r\n" +
                       "</script> \r\n";
            config = GeneralConfigs.GetConfig();
            //先看是否正常登陆
            userid=WebUtils.GetCookieUser();
            password = WebUtils.GetCookiePassword(config.Passwordkey);
            if (userid == "" || password == "")
            {
                Context.Response.Redirect("/login.aspx",true);
                return;
            }
            if (!Page.IsPostBack)
            {
                this.RegisterAdminPageClientScriptBlock();
            }
            if (userEntity == null)
            {
                userEntity = DbHelper.GetInstance().GetUserListEntityByUserID(userid);
            }

			if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" )
			{
				ShowMessage(1);
				return;
			}

			nowdate = Utils.GetDate();
			nowtime = Utils.GetTime();
			nowdatetime = Utils.GetDateTime();

			link = "";
			script = "";
			isseccode =	Utils.InArray(pagename, config.Seccodestatus);

			if ((isseccode))
			{
				if (DNTRequest.GetString("vcode") == "")
				{
					if (pagename == "showforum.aspx")
					{
					}
					else if (pagename.EndsWith("ajax.aspx"))
					{
                        if (DNTRequest.GetString("t") == "quickreply")
					    {
    					    ResponseAjaxVcodeError();
					    }
					}
					else
					{
						AddErrLine("验证码错误");
					}
				}
				else
				{
				}
			}

		
		    m_starttickDateTime = DateTime.Now;
            

			ShowPage();
     
            m_processtime = DateTime.Now.Subtract(m_starttickDateTime).TotalMilliseconds / 1000;
		}