예제 #1
0
        /// <summary>
        /// 获取指定日期的数据
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetData(DateTime date)
        {
            string key = String.Format("{0:yyyyMMdd}", date);

            if (trafficFile.Contains(key))
            {
                return(trafficFile[key]);
            }
            else
            {
                trafficFile.Append(key, defaultJson);
                trafficFile.Flush();
            }

            //try
            //{
            //    trafficFile["ips"] = String.Empty;
            //}
            //catch
            //{
            //    trafficFile.Append("ips", String.Empty);
            //}

            return(defaultJson);
        }
예제 #2
0
        /// <summary>
        /// 更新资料
        /// </summary>
        /// <param name="prefix"></param>
        private static void UpdateKeys(string prefix)
        {
            switch (prefix)
            {
            case "sys":
                sf["license_name"]          = Settings.License_NAME;
                sf["license_key"]           = Settings.License_KEY;
                sf["server_static_enabled"] = Settings.SERVER_STATIC_ENABLED ? "true" : "false";
                sf["server_static"]         = Settings.SERVER_STATIC;
                sf["server_upgrade"]        = Settings.SERVER_UPGRADE;
                sf["sys_admin_tag"]         = Settings.SYS_ADMIN_TAG;
                sf["sys_encode_conf"]       = Settings.SYS_ENCODE_CONF_FILE ? "true" : "false";
                sf["sql_profile_trace"]     = Settings.SQL_PROFILE_TRACE ? "true" : "false";

                //301跳转

                sf["sys_autowww"] = Settings.SYS_AUTOWWW ? "true" : "false";

                //虚拟路径
                //if (!sf.Contains("sys_virthpath"))
                //{
                //    sf.Set("sys_virthpath", Settings.SYS_VIRTHPATH);
                //}
                //else
                //{
                //    sf["sys_virthpath"] = Settings.SYS_VIRTHPATH;
                //}
                break;

            case "db":
                sf["db_prefix"] = Settings.DB_PREFIX;
                break;

            case "tpl":

                //压缩代码
                sf.Set("tpl_usecompress", Settings.TPL_UseCompress ? "true" : "false");
                //使用完整路径
                sf.Set("tpl_usefullpath", Settings.TPL_UseFullPath ? "true" : "false");


                Cms.Template.Register();

                break;

            //优化
            case "opti":

                WebConfig.SetDebug(Settings.Opti_Debug);

                //缓存项
                sf.Set("opti_IndexCacheSeconds", Settings.Opti_IndexCacheSeconds.ToString());
                sf.Set("Opti_GC_Collect_Interval", Settings.Opti_GC_Collect_Interval.ToString());
                sf.Set("opti_ClientCacheSeconds", Settings.Opti_ClientCacheSeconds.ToString());
                break;
            }

            sf.Flush();
        }
예제 #3
0
        /// <summary>
        /// 更新资料
        /// </summary>
        /// <param name="prefix"></param>
        private static void UpdateKeys(string prefix)
        {
            switch (prefix)
            {
            case "sys":
                sf["license_name"]          = Settings.LICENSE_NAME;
                sf["license_key"]           = Settings.LICENSE_KEY;
                sf["server_static_enabled"] = Settings.SERVER_STATIC_ENABLED ? "true" : "false";
                sf["server_static"]         = Settings.SERVER_STATIC;
                sf["server_upgrade"]        = Settings.SERVER_UPGRADE;
                sf["sys_admin_tag"]         = Settings.SYS_ADMIN_TAG;
                sf["sys_encode_conf"]       = Settings.SYS_ENCODE_CONF_FILE ? "true" : "false";
                sf["sql_profile_trace"]     = Settings.SQL_PROFILE_TRACE ? "true" : "false";
                sf.Set("sys_use_upload_raw_path", Settings.SYS_USE_UPLOAD_RAW_NAME?"true":"false");
                sf["sys_www_rd"] = Settings.SYS_WWW_RD.ToString();
                sf.Set("sys_force_https", Settings.SYS_FORCE_HTTPS?"true":"false");
                sf["sys_site_map_path"] = Settings.SYS_SITE_MAP_PATH ?? "";
                //虚拟路径
                //if (!sf.Contains("sys_virthpath"))
                //{
                //    sf.Set("sys_virthpath", Settings.SYS_VIRTHPATH);
                //}
                //else
                //{
                //    sf["sys_virthpath"] = Settings.SYS_VIRTHPATH;
                //}
                break;

            case "db":
                sf["db_prefix"] = Settings.DB_PREFIX;
                break;

            case "tpl":
                sf.Set("tpl_use_cache", Settings.TPL_USE_CACHE?"true":"false");
                //压缩代码
                sf.Set("tpl_use_compress", Settings.TPL_USE_COMPRESS ? "true" : "false");
                //使用完整路径
                sf.Set("tpl_full_url_path", Settings.TPL_FULL_URL_PATH ? "true" : "false");
                Cms.Template.Reload();
                break;

            //优化
            case "opti":
                //缓存项
                sf.Set("perm_index_cache_second", Settings.PERM_INDEX_CACHE_SECOND.ToString());
                sf.Set("opti_gc_collect_interval", Settings.opti_gc_collect_interval.ToString());
                sf.Set("opti_client_cache_seconds", Settings.Opti_ClientCacheSeconds.ToString());
                break;
            }
            sf.Flush();
            if (prefix == "opti")
            {
                WebConfig.SetDebug(Settings.OPTI_DEBUG_MODE);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="workerIndent"></param>
        public PluginPackAttribute(string workerIndent)
        {
            this.WorkIndent = workerIndent;
            bool isChanged = false;
            var  dirPath   = String.Concat(
                AppDomain.CurrentDomain.BaseDirectory,
                PluginConfig.PLUGIN_DIRECTORY,
                workerIndent,
                "/");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath).Create();
            }

            settings = new SettingFile(string.Concat(dirPath, "plugin.config"));

            if (!settings.Contains(PluginSettingKeys.State))
            {
                settings.Set(PluginSettingKeys.State, "Normal");
                isChanged = true;
            }
            if (!settings.Contains(PluginSettingKeys.OverrideUrlIndent))
            {
                settings.Set(PluginSettingKeys.OverrideUrlIndent, "");
                isChanged = true;
            }

            if (isChanged)
            {
                settings.Flush();
            }
        }
예제 #5
0
        public void Save()
        {
            SettingFile sf = new SettingFile(String.Format("{0}templates/{1}/tpl.conf", Cms.PyhicPath, this._tplDirName));

            /**************** 模板设置 ****************/
            sf.Set("TPL_NAME", this.tplName);
            sf.Set("CFG_ShowErrror", this.CfgShowError ? "true" : "false");
            sf.Set("CFG_SitemapSplit", this._cfgSitemapSplit);
            sf.Set("CFG_ArchiveTagsFormat", this._cfgArchiveTagsFormat);
            sf.Set("CFG_NavigatorLinkFormat", this._cfgNavigatorLinkFormat);
            sf.Set("CFG_NavigatorChildFormat", this._cfgNavigatorChildFormat);
            sf.Set("CFG_FriendShowNum", this._cfgFriendShowNum.ToString());
            sf.Set("CFG_FriendLinkFormat", this._cfgFriendLinkFormat);
            sf.Set("CFG_TrafficFormat", this._cfgTrafficFormat);
            sf.Set("CFG_CommentEditorHtml", this._cfgCommentEditorHtml);
            sf.Set("CFG_allowAmousComment", this._cfgAllowAmousComment ? "true" : "false");
            sf.Set("CFG_OutlineLength", this._cfgOutlineLength.ToString());
            sf.Set("CFG_ArchiveFormat", this._cfgArchiveFormat);
            sf.Set("CFG_ArchiveLinkFormat", this._cfgArchiveLinkFormat);
            sf.Set("CFG_PrevArchiveFormat", this._cfgPrevArchiveFormat);
            sf.Set("CFG_NextArchiveFormat", this._cfgNextArchiveFormat);
            sf.Set("CFG_CategoryLinkFormat", this._cfgCategoryLinkFormat);
            sf.Set("CFG_EnabledMobiPage", this._cfgEnabledMobiPage ? "true" : "false");
            sf.Flush();
        }
예제 #6
0
        public void SaveTemplateNames(string json)
        {
            SettingFile sf = new SettingFile(String.Format("{0}templates/{1}/tpl.conf", Cms.PyhicPath, this._tplDirName));

            sf.Set("TPL_NAMES", json);
            sf.Flush();
        }
예제 #7
0
        private static IDictionary <string, TemplateSetting> LoadFromDirectory(string rootDirPath)
        {
            var dir  = new DirectoryInfo(rootDirPath);
            var dirs = dir.GetDirectories();
            IDictionary <string, TemplateSetting> dict = new Dictionary <string, TemplateSetting>(dirs.Length);

            if (!dir.Exists)
            {
                return(dict);
            }
            foreach (var d in dirs)
            {
                if ((d.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    var tplConfigFile = $"{rootDirPath}{d.Name}/tpl.conf";
                    if (!File.Exists(tplConfigFile))
                    {
                        var sf = new SettingFile(tplConfigFile);
                        sf.Set("name", d.Name);
                        sf.Flush();
                    }

                    var ts = new TemplateSetting(d.Name, tplConfigFile)
                    {
                        CfgEnabledMobiPage = Directory.Exists($"{rootDirPath}{d.Name}/_mobile_")
                    };
                    dict.Add(d.Name, ts);
                }
            }

            return(dict);
        }
예제 #8
0
        private static IDictionary <string, TemplateSetting> LoadFromDirectory(string rootDirPath)
        {
            IDictionary <string, TemplateSetting> dict;
            DirectoryInfo dir = new DirectoryInfo(rootDirPath);

            DirectoryInfo[] dirs = dir.GetDirectories();
            dict = new Dictionary <string, TemplateSetting>(dirs.Length);
            if (!dir.Exists)
            {
                return(dict);
            }
            foreach (DirectoryInfo d in dirs)
            {
                if ((d.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    String tplConfigFile = String.Format("{0}{1}/tpl.conf", rootDirPath, d.Name);
                    if (!File.Exists(tplConfigFile))
                    {
                        SettingFile sf = new SettingFile(tplConfigFile);
                        sf.Set("name", d.Name);
                        sf.Flush();
                    }
                    TemplateSetting ts = new TemplateSetting(d.Name, tplConfigFile);
                    ts.CfgEnabledMobiPage = Directory.Exists(String.Format("{0}{1}/_mobile_", rootDirPath, d.Name));
                    dict.Add(d.Name, ts);
                }
            }
            return(dict);
        }
예제 #9
0
        private static void ReflushSetting(MenuFull_ButtonGroup menu)
        {
            String      json = JsonConvert.SerializeObject(menu);
            SettingFile st   = Config.PluginAttr.Settings;

            json = json.Replace(",\"sub_button\":null", "")
                   .Replace(",\"url\":null", "")
                   .Replace(",\"key\":null", "")
                   .Replace("\"type\":null,", "");

            st["Weixin_MenuButtons"] = json;
            st.Flush();

            Variables.MenuButtons = json;
            _buttonGroup          = menu;
        }
예제 #10
0
        internal static void LoadRelatedIndent()
        {
            string      relatedConf = String.Format("{0}{1}related_indent.conf", Cms.PyhicPath, CmsVariables.SITE_CONF_PATH);
            bool        isExists    = File.Exists(relatedConf);
            SettingFile sf          = new SettingFile(relatedConf);
            var         isModify    = false;
            var         isLoaded    = false;
            IDictionary <int, RelateIndent> relatedIndents = ServiceCall.Instance.ContentService.GetRelatedIndents();

            IDictionary <int, RelateIndent> newIndents = new Dictionary <int, RelateIndent>(relatedIndents.Count);

            String key;
            String value;

            foreach (var relatedIndent in relatedIndents)
            {
                key = relatedIndent.Key.ToString();
                if (isExists && sf.Contains(key))
                {
                    value    = sf.Get(key);
                    isLoaded = true;
                }
                else
                {
                    value = relatedIndent.Value.ToString();
                    sf.Set(key, value);
                    isModify = true;
                }
                newIndents.Add(relatedIndent.Key, new RelateIndent(value));
            }

            if (isModify)
            {
                sf.Flush();
            }

            if (isLoaded)
            {
                ServiceCall.Instance.ContentService.SetRelatedIndents(newIndents);
            }
        }
예제 #11
0
        private InstallCode Process(ICompatibleHttpContext context)
        {
            var form     = context.Request;
            var physical = Cms.PhysicPath;

            if (!Directory.Exists(Path.Combine(Cms.PhysicPath, "config")))
            {
                Directory.CreateDirectory(Path.Combine(Cms.PhysicPath, "config")).Create();
            }

            if (File.Exists(Path.Combine(physical, INSTALL_LOCK)))
            {
                return(InstallCode.INSTALLED);
            }

            string licenceKey   = form.Form("licence_key")[0].Trim(),
                   licenceName  = form.Form("licence_name")[0].Trim(),
                   siteName     = form.Form("site_name")[0].Trim(),
                   siteDomain   = form.Form("site_domain")[0].Trim(),
                   siteLanguage = form.Form("site_language"),
                   userName     = form.Form("user_name")[0].Trim(),
                   userPwd      = form.Form("user_pwd")[0].Trim(),
                   dbType       = form.Form("db_type")[0].Trim(),
                   dbServer     = form.Form("db_server")[0].Trim(),
                   dbPort       = form.Form("db_port")[0].Trim(),
                   dbPrefix     = form.Form("db_prefix")[0].Trim(),
                   dbPrefix1    = form.Form("db_prefix1")[0].Trim(),
                   dbName       = form.Form("db_name")[0].Trim(),
                   dbUsr        = form.Form("db_usr")[0].Trim(),
                   dbPwd        = form.Form("db_pwd")[0].Trim(),
                   dbFile       = form.Form("db_file")[0].Trim();

            var dbStr = "";

            #region 检测数据

            if (string.IsNullOrEmpty(licenceName) || string.IsNullOrEmpty(licenceKey))
            {
                return(InstallCode.NO_LICENCE);
            }

            if (string.IsNullOrEmpty(siteName))
            {
                return(InstallCode.NO_SITE_NAME);
            }

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(userPwd))
            {
                return(InstallCode.NO_USER);
            }

            #endregion

            #region 初始化数据库设置

            //数据表前缀
            if (string.IsNullOrEmpty(dbPrefix))
            {
                dbPrefix = dbPrefix1;
            }

            const string dbDirName = "data";

            //移动Access或SQLite数据库
            if (dbType == "sqlite")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".db";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".db";
                }

                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }

                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else if (dbType == "oledb")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".mdb";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".mdb";
                }

                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }

                File.Copy(physical + FILE_DB_OLEDB, physical + dbDirName + "/" + dbFile, true);
                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else
            {
                //数据库资料不全
                if (string.IsNullOrEmpty(dbServer) || string.IsNullOrEmpty(dbUsr) || string.IsNullOrEmpty(dbName) ||
                    string.IsNullOrEmpty(dbPrefix))
                {
                    return(InstallCode.DB_ERROR);
                }

                if (!Regex.IsMatch(dbPort, "^\\d+$"))
                {
                    return(InstallCode.DB_ERROR_PORT);
                }

                if (dbType == "mysql")
                {
                    dbStr = $"server={dbServer};database={dbName};uid={dbUsr};pwd={dbPwd};port={dbPort};charset=utf8";
                }
                else if (dbType == "mssql")
                {
                    dbStr = $"server={dbServer},{dbPort};database={dbName};uid={dbUsr};pwd={dbPwd}";
                }
                else
                {
                    return(InstallCode.DB_UNKNOWN);
                }
            }

            #endregion

            #region 写入配置

            if (File.Exists(physical + FILE_SETTING))
            {
                File.Delete(physical + FILE_SETTING);
            }

            var file = new SettingFile(physical + FILE_SETTING);
            file.Set("license_key", licenceKey);
            file.Set("license_name", licenceName);
            file.Set("server_static", "");
            file.Set("server_static_enabled", "false");
            file.Set("db_type", dbType);
            file.Set("db_conn", dbStr);
            file.Set("db_prefix", dbPrefix);

            file.Set("mm_avatar_path", "/file/avatar/");
            file.Flush();

            #endregion

            #region 初始化数据库

            if (!ExtraDB(dbType, dbStr, dbPrefix))
            {
                return(InstallCode.DB_INIT_ERROR);
            }

            #endregion

            #region 初始化数据

            var siteId = InitSite(dbPrefix, siteName, siteDomain, int.Parse(siteLanguage));
            InitUserAndCredential(dbPrefix, userName, userPwd);
            var catId = InitCategory(dbPrefix, siteId);
            InitArchive(dbPrefix, siteId, catId);

            #endregion


            //创建安装文件
            File.Create(string.Concat(physical, INSTALL_LOCK));
            Cms.Init(BootFlag.Normal, null);
            // 重启cms
            Cms.Reload();
            return(InstallCode.SUCCESS);
        }
        public PluginPackAttribute(string workerIndent)
        {
            this.WorkIndent = workerIndent;
            bool isChanged = false;
            var dirPath = String.Concat(
                AppDomain.CurrentDomain.BaseDirectory,
                PluginConfig.PLUGIN_DIRECTORY,
                workerIndent,
                "/");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath).Create();
            }

            settings = new SettingFile(string.Concat(dirPath, "plugin.config"));

            if (!settings.Contains("state"))
            {
                settings.Append("state", "Normal");
                isChanged = true;
            }
            if (!settings.Contains("override.url.indent"))
            {
                settings.Append("override.url.indent", "");
                isChanged = true;
            }

            if (isChanged)
            {
                settings.Flush();
            }
        }
예제 #13
0
        public InstallCode Process(HttpContext context)
        {
            NameValueCollection form = context.Request.Form;
            string physical          = Cms.PyhicPath;

            if (!Directory.Exists(Cms.PyhicPath + "config"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "config").Create();
            }

            if (File.Exists(String.Concat(physical, INSTALL_LOCK)))
            {
                return(InstallCode.INSTALLED);
            }

            string licenceKey   = form["licence_key"].Trim(),
                   licenceName  = form["licence_name"].Trim(),
                   siteName     = form["site_name"].Trim(),
                   siteDomain   = form["site_domain"].Trim(),
                   siteLanguage = form["site_language"],
                   userName     = form["user_name"].Trim(),
                   userPwd      = form["user_pwd"].Trim(),
                   dbType       = form["db_type"].Trim(),
                   dbServer     = form["db_server"].Trim(),
                   dbPrefix     = form["db_prefix"].Trim(),
                   dbPrefix1    = form["db_prefix1"].Trim(),
                   dbName       = form["db_name"].Trim(),
                   dbUsr        = form["db_usr"].Trim(),
                   dbPwd        = form["db_pwd"].Trim(),
                   dbFile       = form["db_file"].Trim();

            string dbStr = "";

            #region 检测数据
            if (String.IsNullOrEmpty(licenceName) || String.IsNullOrEmpty(licenceKey))
            {
                return(InstallCode.NO_LICENCE);
            }
            if (String.IsNullOrEmpty(siteName))
            {
                return(InstallCode.NO_SITE_NAME);
            }

            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(userPwd))
            {
                return(InstallCode.NO_USER);
            }

            #endregion

            #region 初始化数据库设置

            //数据表前缀
            if (String.IsNullOrEmpty(dbPrefix))
            {
                dbPrefix = dbPrefix1;
            }

            const String dbDirName = "data";

            //移动Access或SQLite数据库
            if (dbType == "sqlite")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".db";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".db";
                }
                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }
                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else if (dbType == "oledb")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".mdb";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".mdb";
                }

                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }
                File.Copy(physical + FILE_DB_OLEDB, physical + dbDirName + "/" + dbFile, true);
                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else
            {
                //数据库资料不全
                if (String.IsNullOrEmpty(dbServer) || String.IsNullOrEmpty(dbUsr) || String.IsNullOrEmpty(dbName) || String.IsNullOrEmpty(dbPrefix))
                {
                    return(InstallCode.DB_ERROR);
                }

                if (dbType == "mysql")
                {
                    dbStr = String.Format("server={0};database={1};uid={2};pwd={3};charset=utf8", dbServer, dbName, dbUsr, dbPwd);
                }
                else if (dbType == "mssql")
                {
                    dbStr = String.Format("server={0};database={1};uid={2};pwd={3}", dbServer, dbName, dbUsr, dbPwd);
                }
                else
                {
                    return(InstallCode.DB_UNKNOWN);
                }
            }

            #endregion

            #region 写入配置

            if (File.Exists(physical + FILE_SETTING))
            {
                File.Delete(physical + FILE_SETTING);
            }
            SettingFile file = new SettingFile(physical + FILE_SETTING);
            file.Set("license_key", licenceKey);
            file.Set("license_name", licenceName);
            file.Set("server_static", "");
            file.Set("server_static_enabled", "false");

            file.Set("db_type", dbType);
            file.Set("db_conn", dbStr);
            file.Set("db_prefix", dbPrefix);

            file.Set("mm_avatar_path", "/file/avatar/");
            file.Flush();

            #endregion

            #region 初始化数据库

            if (!ExtraDB(dbType, dbStr, dbPrefix))
            {
                return(InstallCode.DB_INIT_ERROR);
            }

            #endregion

            #region 初始化数据
            int siteId = this.InitSite(dbPrefix, siteName, siteDomain, int.Parse(siteLanguage));
            this.InitUserAndCredential(dbPrefix, userName, userPwd);
            int catId = this.InitCategory(dbPrefix, siteId);
            this.InitArchive(dbPrefix, siteId, catId);

            #endregion


            //创建安装文件
            File.Create(String.Concat(physical, INSTALL_LOCK));

            Settings.TurnOffDebug();

            Cms.Init(BootFlag.Normal, null);

            // 重启
            HttpRuntime.UnloadAppDomain();
            //AppDomain.Unload(AppDomain.CurrentDomain);

            return(InstallCode.SUCCESS);
        }
예제 #14
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>返回加载消息,如成功返回空</returns>
        internal static string Load(string filePath)
        {
            cmsConfigFile = filePath;

            //从配置文件中加载
            SettingFile sf = new SettingFile(cmsConfigFile);

            Settings.loaded = true;
            bool settingChanged = false;

            //try
            // {
            Settings.License_NAME = sf.Contains("license_name") ? sf["license_name"] : "评估用户";
            Settings.License_KEY  = sf.Contains("license_key") ? sf["license_key"] : String.Empty;
            Settings.SYS_AUTOWWW  = sf.Contains("sys_autowww") ? sf["sys_autowww"] == "true" : false;                    //自动WWW

            #region 读取模板选项

            Settings.TPL_UseFullPath = sf.Contains("tpl_usefullpath") ? sf["tpl_usefullpath"] == "true" : true;
            Settings.TPL_UseCompress = sf.Contains("tpl_usecompress") ? sf["tpl_usecompress"] == "true" : false;


            #endregion

            Settings.DB_TYPE   = sf["db_type"];
            Settings.DB_CONN   = sf["db_conn"];
            Settings.DB_PREFIX = sf["db_prefix"];


            Settings.MM_AVATAR_PATH = sf["mm_avatar_path"];


            /**************** 优化项 ******************/
            Settings.Opti_Debug = WebConfig.IsDebug();

            //缓存项
            if (sf.Contains("opti_IndexCacheSeconds"))
            {
                int.TryParse(sf["opti_IndexCacheSeconds"], out Settings.Opti_IndexCacheSeconds);
            }

            if (sf.Contains("opti_ClientCacheSeconds"))
            {
                int.TryParse(sf["opti_ClientCacheSeconds"], out Settings.Opti_ClientCacheSeconds);
            }

            if (sf.Contains("Opti_GC_Collect_Interval"))
            {
                int.TryParse(sf["Opti_GC_Collect_Interval"], out Settings.Opti_GC_Collect_Interval);
            }


            /**************** 静态服务器 ******************/

            if (sf.Contains("server_static"))
            {
                Settings.SERVER_STATIC = sf["server_static"];
                if (Settings.SERVER_STATIC.Length == 0)
                {
                    Settings.SERVER_STATIC = Server._defaultStaticServer;
                }
            }
            else
            {
                sf.Append("server_static", Server._defaultStaticServer);
                Settings.SERVER_STATIC = Server._defaultStaticServer;
                settingChanged         = true;
            }

            if (sf.Contains("server_static_enabled"))
            {
                Settings.SERVER_STATIC_ENABLED = sf["server_static_enabled"] == "true";
            }
            else
            {
                sf.Append("server_static_enabled", "false");
                settingChanged = true;
            }


            if (sf.Contains("sys_admin_tag"))
            {
                Settings.SYS_ADMIN_TAG = sf["sys_admin_tag"];
            }
            else
            {
                sf.Append("sys_admin_tag", Settings.SYS_ADMIN_TAG);
                settingChanged = true;
            }

            if (settingChanged)
            {
                sf.Flush();
            }


            return(string.Empty);

            /*
             * }
             * catch (Exception ex)
             * {
             * const string strtpl = "配置文件不正确,请检查!位置:{0}。{1}";
             * string _file = filePath.Replace("/", "\\").Replace("\\\\", "\\");
             *
             * return string.Format(strtpl, _file,
             * ex.GetType() == typeof(ArgumentOutOfRangeException) ? "此错误可能因为缺少系统所需的配置而引发。" :
             * string.Empty
             * );
             * }*/
        }
예제 #15
0
        /// <summary>
        /// 更新资料
        /// </summary>
        /// <param name="prefix"></param>
        public static void Update(string prefix)
        {
            SettingFile sf = new SettingFile(cmsConfigFile);

            switch (prefix)
            {
            case "sys":
                sf["license_name"]          = Settings.License_NAME;
                sf["license_key"]           = Settings.License_KEY;
                sf["server_static_enabled"] = Settings.SERVER_STATIC_ENABLED?"true":"false";
                sf["server_static"]         = Settings.SERVER_STATIC;
                sf["sys_admin_tag"]         = Settings.SYS_ADMIN_TAG;

                //301跳转
                if (!sf.Contains("sys_autowww"))
                {
                    sf.Append("sys_autowww", Settings.SYS_AUTOWWW ? "true" : "false");
                }
                else
                {
                    sf["sys_autowww"] = Settings.SYS_AUTOWWW ? "true" : "false";
                }

                //虚拟路径
                //if (!sf.Contains("sys_virthpath"))
                //{
                //    sf.Append("sys_virthpath", Settings.SYS_VIRTHPATH);
                //}
                //else
                //{
                //    sf["sys_virthpath"] = Settings.SYS_VIRTHPATH;
                //}
                break;

            case "db":
                sf["db_prefix"] = Settings.DB_PREFIX;
                break;

            case "tpl":

                //压缩代码
                if (!sf.Contains("tpl_usecompress"))
                {
                    sf.Append("tpl_usecompress", Settings.TPL_UseCompress ? "true" : "false");
                }
                else
                {
                    sf["tpl_usecompress"] = Settings.TPL_UseCompress ? "true" : "false";
                }

                //使用完整路径
                if (!sf.Contains("tpl_usefullpath"))
                {
                    sf.Append("tpl_usefullpath", Settings.TPL_UseFullPath ? "true" : "false");
                }
                else
                {
                    sf["tpl_usefullpath"] = Settings.TPL_UseFullPath ? "true" : "false";
                }


                Cms.Template.Register();

                break;

            //优化
            case "opti":

                WebConfig.SetDebug(Settings.Opti_Debug);

                //缓存项
                if (!sf.Contains("opti_IndexCacheSeconds"))
                {
                    sf.Append("opti_IndexCacheSeconds", Settings.Opti_IndexCacheSeconds.ToString());
                }
                else
                {
                    sf["opti_IndexCacheSeconds"] = Settings.Opti_IndexCacheSeconds.ToString();
                }

                if (!sf.Contains("Opti_GC_Collect_Interval"))
                {
                    sf.Append("Opti_GC_Collect_Interval", Settings.Opti_GC_Collect_Interval.ToString());
                }
                else
                {
                    sf["Opti_GC_Collect_Interval"] = Settings.Opti_GC_Collect_Interval.ToString();
                }

                if (!sf.Contains("opti_ClientCacheSeconds"))
                {
                    sf.Append("opti_ClientCacheSeconds", Settings.Opti_ClientCacheSeconds.ToString());
                }
                else
                {
                    sf["opti_ClientCacheSeconds"] = Settings.Opti_ClientCacheSeconds.ToString();
                }


                break;
            }

            //
            //Version:兼容更新站点
            //
            SiteDto site = Cms.Context.CurrentSite;

            if (site.SiteId > 0)
            {
                if (sf.Contains("idx_title"))
                {
                    site.SeoTitle = sf["idx_title"];
                    sf.Remove("idx_title");
                }
                if (sf.Contains("idx_keywords"))
                {
                    site.SeoKeywords = sf["idx_keywords"];
                    sf.Remove("idx_keywords");
                }
                if (sf.Contains("idx_description"))
                {
                    site.SeoDescription = sf["idx_description"];
                    sf.Remove("idx_description");
                }
                if (sf.Contains("sys_alias"))
                {
                    sf.Remove("sys_alias");
                }
            }

            if (sf.Contains("sys_name"))
            {
                if (sf.Contains("license_name"))
                {
                    sf["license_name"] = sf["sys_name"];
                    sf["license_key"]  = sf["sys_key"];
                }
                else
                {
                    sf.Append("license_name", sf["sys_name"]);
                    sf.Append("license_key", sf["sys_key"]);
                }
                sf.Remove("sys_name");
                sf.Remove("sys_key");
            }

            sf.Flush();
        }
예제 #16
0
        public void Save()
        {
            SettingFile sf = new SettingFile(String.Format("{0}templates/{1}/tpl.conf", Cms.PyhicPath, this.tplName));

            /**************** 模板设置 ****************/
            if (sf.Contains("CFG_ShowErrror"))
            {
                sf["CFG_ShowErrror"] = this.CFG_ShowError?"true":"false";
            }
            else
            {
                sf.Append("CFG_ShowErrror", this.CFG_ShowError?"true":"false");
            }

            if (sf.Contains("CFG_SitemapSplit"))
            {
                sf["CFG_SitemapSplit"] = this.cfg_sitemapSplit;
            }
            else
            {
                sf.Append("CFG_SitemapSplit", this.cfg_sitemapSplit);
            }
            if (sf.Contains("CFG_ArchiveTagsFormat"))
            {
                sf["CFG_ArchiveTagsFormat"] = this.cfg_ArchiveTagsFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveTagsFormat", this.cfg_ArchiveTagsFormat);
            }
            if (sf.Contains("CFG_NavigatorLinkFormat"))
            {
                sf["CFG_NavigatorLinkFormat"] = this.cfg_navigatorLinkFormat;
            }
            else
            {
                sf.Append("CFG_NavigatorLinkFormat", this.cfg_navigatorLinkFormat);
            }
            if (sf.Contains("CFG_NavigatorChildFormat"))
            {
                sf["CFG_NavigatorChildFormat"] = this.cfg_navigatorChildFormat;
            }
            else
            {
                sf.Append("CFG_NavigatorChildFormat", this.cfg_navigatorChildFormat);
            }
            if (sf.Contains("CFG_FriendShowNum"))
            {
                sf["CFG_FriendShowNum"] = this.cfg_friendShowNum.ToString();
            }
            else
            {
                sf.Append("CFG_FriendShowNum", this.cfg_friendShowNum.ToString());
            }
            if (sf.Contains("CFG_FriendLinkFormat"))
            {
                sf["CFG_FriendLinkFormat"] = this.cfg_friendLinkFormat;
            }
            else
            {
                sf.Append("CFG_FriendLinkFormat", this.cfg_friendLinkFormat);
            }
            if (sf.Contains("CFG_TrafficFormat"))
            {
                sf["CFG_TrafficFormat"] = this.cfg_trafficFormat;
            }
            else
            {
                sf.Append("CFG_TrafficFormat", this.cfg_trafficFormat);
            }
            if (sf.Contains("CFG_CommentEditorHtml"))
            {
                sf["CFG_CommentEditorHtml"] = this.cfg_commentEditorHtml;
            }
            else
            {
                sf.Append("CFG_CommentEditorHtml", this.cfg_commentEditorHtml);
            }
            if (sf.Contains("CFG_allowAmousComment"))
            {
                sf["CFG_allowAmousComment"] = this.cfg_allowAmousComment ? "true" : "false";
            }
            else
            {
                sf.Append("CFG_allowAmousComment", this.cfg_allowAmousComment ? "true" : "false");
            }
            if (sf.Contains("CFG_OutlineLength"))
            {
                sf["CFG_OutlineLength"] = this.cfg_outlineLength.ToString();
            }
            else
            {
                sf.Append("CFG_OutlineLength", this.cfg_outlineLength.ToString());
            }
            if (sf.Contains("CFG_ArchiveFormat"))
            {
                sf["CFG_ArchiveFormat"] = this.cfg_archiveFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveFormat", this.cfg_archiveFormat);
            }
            if (sf.Contains("CFG_ArchiveLinkFormat"))
            {
                sf["CFG_ArchiveLinkFormat"] = this.cfg_archiveLinkFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveLinkFormat", this.cfg_archiveLinkFormat);
            }
            if (sf.Contains("CFG_PrevArchiveFormat"))
            {
                sf["CFG_PrevArchiveFormat"] = this.cfg_prevArchiveFormat;
            }
            else
            {
                sf.Append("CFG_PrevArchiveFormat", this.cfg_prevArchiveFormat);
            }
            if (sf.Contains("CFG_NextArchiveFormat"))
            {
                sf["CFG_NextArchiveFormat"] = this.cfg_nextArchiveFormat;
            }
            else
            {
                sf.Append("CFG_NextArchiveFormat", this.cfg_nextArchiveFormat);
            }

            if (sf.Contains("CFG_CategoryLinkFormat"))
            {
                sf["CFG_CategoryLinkFormat"] = this.cfg_categoryLinkFormat;
            }
            else
            {
                sf.Append("CFG_CategoryLinkFormat", this.cfg_categoryLinkFormat);
            }
            sf.Flush();
        }
예제 #17
0
		/// <summary>
		/// 更新资料
		/// </summary>
		/// <param name="prefix"></param>
		public static void Update(string prefix)
		{
			SettingFile sf = new SettingFile(cmsConfigFile);

			switch (prefix)
			{
				case "sys":
					sf["license_name"] = Settings.License_NAME;
					sf["license_key"] = Settings.License_KEY;
					sf["server_static_enabled"]=Settings.SERVER_STATIC_ENABLED?"true":"false";
                    sf["server_static"] = Settings.SERVER_STATIC;
                    sf["sys_admin_tag"] = Settings.SYS_ADMIN_TAG;

					//301跳转
					if (!sf.Contains("sys_autowww"))
					{
						sf.Append("sys_autowww", Settings.SYS_AUTOWWW ? "true" : "false");
					}
					else
					{
						sf["sys_autowww"] = Settings.SYS_AUTOWWW ? "true" : "false";
					}

					//虚拟路径
					//if (!sf.Contains("sys_virthpath"))
					//{
					//    sf.Append("sys_virthpath", Settings.SYS_VIRTHPATH);
					//}
					//else
					//{
					//    sf["sys_virthpath"] = Settings.SYS_VIRTHPATH;
					//}
					break;

				case "db":
					sf["db_prefix"] = Settings.DB_PREFIX;
					break;

				case "tpl":
					
					//压缩代码
					if (!sf.Contains("tpl_usecompress"))
					{
						sf.Append("tpl_usecompress", Settings.TPL_UseCompress ? "true" : "false");
					}
					else
					{
						sf["tpl_usecompress"] = Settings.TPL_UseCompress ? "true" : "false";
					}

					//使用完整路径
					if (!sf.Contains("tpl_usefullpath"))
					{
						sf.Append("tpl_usefullpath", Settings.TPL_UseFullPath ? "true" : "false");
					}
					else
					{
						sf["tpl_usefullpath"] = Settings.TPL_UseFullPath ? "true" : "false";
					}


					Cms.Template.Register();

					break;

					//优化
				case "opti":

					WebConfig.SetDebug(Settings.Opti_Debug);

					//缓存项
					if (!sf.Contains("opti_IndexCacheSeconds"))
					{
						sf.Append("opti_IndexCacheSeconds", Settings.Opti_IndexCacheSeconds.ToString());
					}
					else
					{
						sf["opti_IndexCacheSeconds"] = Settings.Opti_IndexCacheSeconds.ToString();
					}

                    if (!sf.Contains("Opti_GC_Collect_Interval"))
					{
                        sf.Append("Opti_GC_Collect_Interval", Settings.Opti_GC_Collect_Interval.ToString());
					}
					else
					{
                        sf["Opti_GC_Collect_Interval"] = Settings.Opti_GC_Collect_Interval.ToString();
					}

					if (!sf.Contains("opti_ClientCacheSeconds"))
					{
						sf.Append("opti_ClientCacheSeconds", Settings.Opti_ClientCacheSeconds.ToString());
					}
					else
					{
						sf["opti_ClientCacheSeconds"] = Settings.Opti_ClientCacheSeconds.ToString();
					}


					break;
			}

			//
			//Version:兼容更新站点
			//
			SiteDto site = Cms.Context.CurrentSite;
			if (site.SiteId>0)
			{
				if (sf.Contains("idx_title"))
				{
					site.SeoTitle = sf["idx_title"];
					sf.Remove("idx_title");
				}
				if (sf.Contains("idx_keywords"))
				{
					site.SeoKeywords = sf["idx_keywords"];
					sf.Remove("idx_keywords");
				}
				if (sf.Contains("idx_description"))
				{
					site.SeoDescription = sf["idx_description"];
					sf.Remove("idx_description");
				}
				if (sf.Contains("sys_alias"))
				{
					sf.Remove("sys_alias");
				}
			}

			if (sf.Contains("sys_name"))
			{
				if(sf.Contains("license_name"))
				{
					sf["license_name"] = sf["sys_name"];
					sf["license_key"] = sf["sys_key"];
				}
				else
				{
					
					sf.Append("license_name", sf["sys_name"]);
					sf.Append("license_key",sf["sys_key"]);
				}
				sf.Remove("sys_name");
				sf.Remove("sys_key");
			}

			sf.Flush();
		}
예제 #18
0
		/// <summary>
		/// 加载配置文件
		/// </summary>
		/// <param name="filePath">文件路径</param>
		/// <returns>返回加载消息,如成功返回空</returns>
		internal static string Load(string filePath)
		{
			cmsConfigFile = filePath;

			//从配置文件中加载
			SettingFile sf = new SettingFile(cmsConfigFile);
			Settings.loaded = true;
			bool settingChanged=false;

			//try
			// {
			Settings.License_NAME = sf.Contains("license_name") ? sf["license_name"] : "评估用户";
			Settings.License_KEY = sf.Contains("license_key") ? sf["license_key"] : String.Empty;
			Settings.SYS_AUTOWWW = sf.Contains("sys_autowww") ? sf["sys_autowww"] == "true" : false;         //自动WWW

			#region 读取模板选项

			Settings.TPL_UseFullPath = sf.Contains("tpl_usefullpath") ? sf["tpl_usefullpath"] == "true" : true;
			Settings.TPL_UseCompress = sf.Contains("tpl_usecompress") ? sf["tpl_usecompress"] == "true" : false;


			#endregion

			Settings.DB_TYPE = sf["db_type"];
			Settings.DB_CONN = sf["db_conn"];
			Settings.DB_PREFIX = sf["db_prefix"];


			Settings.MM_AVATAR_PATH = sf["mm_avatar_path"];


			/**************** 优化项 ******************/
			Settings.Opti_Debug = WebConfig.IsDebug();

			//缓存项
			if (sf.Contains("opti_IndexCacheSeconds"))
			{
				int.TryParse(sf["opti_IndexCacheSeconds"], out Settings.Opti_IndexCacheSeconds);
			}

			if (sf.Contains("opti_ClientCacheSeconds"))
			{
				int.TryParse(sf["opti_ClientCacheSeconds"], out  Settings.Opti_ClientCacheSeconds);
			}

            if (sf.Contains("Opti_GC_Collect_Interval"))
			{
                int.TryParse(sf["Opti_GC_Collect_Interval"], out  Settings.Opti_GC_Collect_Interval);
			}
            
			
			/**************** 静态服务器 ******************/
			
			if(sf.Contains("server_static"))
			{
				Settings.SERVER_STATIC=sf["server_static"];
				if(Settings.SERVER_STATIC.Length==0)
				{
					Settings.SERVER_STATIC=Server._defaultStaticServer;
				}
			}
			else
			{
				sf.Append("server_static",Server._defaultStaticServer);
				Settings.SERVER_STATIC=Server._defaultStaticServer;
				settingChanged=true;
			}
			
			if(sf.Contains("server_static_enabled"))
			{
				Settings.SERVER_STATIC_ENABLED=sf["server_static_enabled"]=="true";
			}
			else
			{
				sf.Append("server_static_enabled","false");
				settingChanged=true;
			}

			
			if(sf.Contains("sys_admin_tag"))
			{
				Settings.SYS_ADMIN_TAG=sf["sys_admin_tag"];
			}
			else
			{
				sf.Append("sys_admin_tag",Settings.SYS_ADMIN_TAG);
				settingChanged=true;
			}
			
			if(settingChanged)sf.Flush();
			
			
			return string.Empty;
			
			/*
        }
        catch (Exception ex)
        {
            const string strtpl = "配置文件不正确,请检查!位置:{0}。{1}";
            string _file = filePath.Replace("/", "\\").Replace("\\\\", "\\");

            return string.Format(strtpl, _file,
               ex.GetType() == typeof(ArgumentOutOfRangeException) ? "此错误可能因为缺少系统所需的配置而引发。" :
               string.Empty
               );
        }*/
		}
예제 #19
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>返回加载消息,如成功返回空</returns>
        private static void Load(string filePath)
        {
            cmsConfFile = filePath;
            //从配置文件中加载
            SettingFile sf = new SettingFile(cmsConfFile);

            Settings.loaded = true;
            bool settingChanged = false;

            //try
            // {
            Settings.LICENSE_NAME            = sf.Contains("license_name") ? sf["license_name"] : "评估用户";
            Settings.LICENSE_KEY             = sf.Contains("license_key") ? sf["license_key"] : String.Empty;
            Settings.SYS_WWW_RD              = GetInt(sf, "sys_www_rd");
            Settings.SYS_FORCE_HTTPS         = CheckTrueValue(sf, "sys_force_https");
            Settings.SYS_USE_UPLOAD_RAW_NAME = CheckTrueValue(sf, "sys_use_upload_raw_path");

            #region 读取模板选项

            Settings.TPL_FULL_URL_PATH = !sf.Contains("tpl_full_url_path") || sf["tpl_full_url_path"] == "true";
            Settings.TPL_USE_COMPRESS  = sf.Contains("tpl_use_compress") && sf["tpl_use_compress"] == "true";
            Settings.TPL_USE_CACHE     = !sf.Contains("tpl_use_cache") || sf["tpl_use_cache"] == "true";

            #endregion

            Settings.DB_TYPE   = sf["db_type"];
            Settings.DB_CONN   = sf["db_conn"];
            Settings.DB_PREFIX = sf["db_prefix"];

            Settings.MM_AVATAR_PATH = sf["mm_avatar_path"];


            /**************** 优化项 ******************/
            Settings.OPTI_DEBUG_MODE = WebConfig.IsDebug();

            //缓存项
            if (sf.Contains("perm_index_cache_second"))
            {
                Int32.TryParse(sf["perm_index_cache_second"], out Settings.PERM_INDEX_CACHE_SECOND);
            }

            if (sf.Contains("opti_client_cache_seconds"))
            {
                Int32.TryParse(sf["opti_client_cache_seconds"], out Settings.Opti_ClientCacheSeconds);
            }

            if (sf.Contains("opti_gc_collect_interval"))
            {
                Int32.TryParse(sf["opti_gc_collect_interval"], out Settings.opti_gc_collect_interval);
            }


            /**************** 静态服务器 ******************/

            if (sf.Contains("server_static"))
            {
                Settings.SERVER_STATIC = sf["server_static"];
                if (Settings.SERVER_STATIC.Length == 0)
                {
                    Settings.SERVER_STATIC = Server.DefaultStaticServer;
                }
            }
            else
            {
                sf.Set("server_static", Server.DefaultStaticServer);
                Settings.SERVER_STATIC = Server.DefaultStaticServer;
                settingChanged         = true;
            }


            if (sf.Contains("server_upgrade"))
            {
                Settings.SERVER_UPGRADE = sf["server_upgrade"];
                if (Settings.SERVER_UPGRADE.Length == 0)
                {
                    Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                }
            }
            else
            {
                sf.Set("server_upgrade", Server.DefaultUpgradeServer);
                Settings.SERVER_UPGRADE = Server.DefaultUpgradeServer;
                settingChanged          = true;
            }

            if (sf.Contains("server_static_enabled"))
            {
                Settings.SERVER_STATIC_ENABLED = sf["server_static_enabled"] == "true";
            }
            else
            {
                sf.Set("server_static_enabled", "false");
                settingChanged = true;
            }

            if (sf.Contains("sys_encode_conf"))
            {
                Settings.SYS_ENCODE_CONF_FILE = sf["sys_encode_conf"] == "true";
            }
            else
            {
                sf.Set("sys_encode_conf", Settings.SYS_ENCODE_CONF_FILE ? "true" : "false");
                settingChanged = true;
            }

            if (sf.Contains("sql_profile_trace"))
            {
                Settings.SQL_PROFILE_TRACE = sf["sql_profile_trace"] == "true";
            }
            else
            {
                sf.Set("sql_profile_trace", Settings.SQL_PROFILE_TRACE ? "true" : "false");
                settingChanged = true;
            }
            if (sf.Contains("sys_admin_tag"))
            {
                Settings.SYS_ADMIN_TAG = sf["sys_admin_tag"];
            }
            else
            {
                sf.Set("sys_admin_tag", Settings.SYS_ADMIN_TAG);
                settingChanged = true;
            }

            if (sf.Contains("sys_site_map_path"))
            {
                Settings.SYS_SITE_MAP_PATH = sf["sys_site_map_path"];
            }
            else
            {
                sf.Set("sys_site_map_path", "");
                settingChanged = true;
            }

            if (settingChanged)
            {
                sf.Flush();
            }
        }
예제 #20
0
        public InstallCode Process(HttpContext context)
        {

          NameValueCollection form=context.Request.Form;
            string physical = Cms.PyhicPath;

            if (!Directory.Exists(Cms.PyhicPath + "config"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "config").Create();
            }

            if (System.IO.File.Exists(String.Concat(physical, INSTALL_LOCK)))
            {
                return InstallCode.Installed;
            }

            string t_key = form["t_key"],
                   t_name = form["t_name"],
                   site_name = form["site_name"],
                   site_domain = form["site_domain"],
                   site_language = form["site_language"],
                   user_name=form["user_name"],
                   user_pwd=form["user_pwd"],
                   db_type = form["db_type"],
                   db_server = form["db_server"],
                   db_prefix = form["db_prefix"],
                   db_prefix1 = form["db_prefix1"],
                   db_name = form["db_name"],
                   db_usr = form["db_usr"],
                   db_pwd = form["db_pwd"],
                   db_file = form["db_file"];

            string db_str = "";

            #region 检测数据

            if (String.IsNullOrEmpty(user_name) || String.IsNullOrEmpty(user_pwd))
            {
                return InstallCode.NO_USER;
            }

            #endregion

            #region 初始化数据库设置

            //数据表前缀
            if (String.IsNullOrEmpty(db_prefix)) db_prefix = db_prefix1;


            //移动Access或SQLite数据库
            if (db_type == "sqlite")
            {
                if (db_file == "")
                {
                    db_file = "#db.db3";
                }
                else if (db_file.IndexOf(".") == -1)
                {
                    db_file += ".db3";
                }
                System.IO.File.Copy(physical + FILE_DB_SQLITE, physical + "data/" + db_file, true);
                db_str = "Data Source=$ROOT/data/" + db_file;
            }
            else if (db_type == "oledb")
            {
                if (db_file == "")
                {
                    db_file = "#db.mdb";
                }
                else if (db_file.IndexOf(".") == -1)
                {
                    db_file += ".mdb";
                }
                System.IO.File.Copy(physical + FILE_DB_OLEDB, physical + "data/" + db_file, true);
                db_str = "Data Source=$ROOT/data/" + db_file;
            }
            else
            {
                //数据库资料不全
                if (String.IsNullOrEmpty(db_server) || String.IsNullOrEmpty(db_usr) || String.IsNullOrEmpty(db_name) || String.IsNullOrEmpty(db_prefix))
                {
                    return InstallCode.DB_ERROR;
                }

                if (db_type == "mysql")
                {
                    db_str = String.Format("server={0};database={1};uid={2};pwd={3};charset=utf8", db_server, db_name, db_usr, db_pwd);
                }
                else if (db_type == "mssql")
                {
                    db_str = String.Format("server={0};database={1};uid={2};pwd={3}", db_server, db_name, db_usr, db_pwd);
                }
                else
                {
                    return InstallCode.DB_UNKNOWN;
                }
            }

            #endregion

            #region 写入配置

            if (System.IO.File.Exists(physical + FILE_SETTING))
            {
                System.IO.File.Delete(physical + FILE_SETTING);
            }
            SettingFile file = new SettingFile(physical + FILE_SETTING);
            file.Append("license_key", t_key);
            file.Append("license_name", t_name);
            file.Append("server_static","");
            file.Append("server_static_enabled","false");

            file.Append("db_type", db_type);
            file.Append("db_conn", db_str);
            file.Append("db_prefix", db_prefix);

            file.Append("mm_avatar_path", "/file/avatar/");
            file.Flush();

            #endregion

            #region 初始化数据库

            if (!ExtraDB(db_type, db_str, db_prefix))
            {
                return InstallCode.DB_INIT_ERROR;
            }

            #endregion

            #region 初始化数据

            //默认数据为:
            // cms_sites        siteid为1的站点
            // cms_categories   默认的about分类
            // cms_usergroups


            //更新默认站点
            this.db.ExecuteNonQuery(new SqlQuery(
                String.Format("UPDATE {0}sites SET domain=@domain,name=@name,tpl=@tpl,seotitle=@name where siteid=1", db_prefix),
                new object[,]{
                    {"@domain",site_domain},
                    {"@name",site_name},
                    {"@tpl","default"}
                }));

            //创建管理用户
            this.db.ExecuteNonQuery(new SqlQuery(
                String.Format(@"
                        INSERT INTO {0}users (
                        siteid ,
                        username ,
                        password ,
                        name ,
                        groupid ,
                        available ,
                        createdate ,
                        lastlogindate ) VALUES (0,@username,@password,@name,1,1,@dt,@dt)
                    ", db_prefix),
                     new object[,]{
                         {"@username",user_name},
                         {"@password",  user_pwd.Encode16MD5().EncodeMD5()},
                         {"@name","管理员"},
                         {"@dt",DateTime.Now}
                     }));


            #endregion


            //创建安装文件
            System.IO.File.Create(String.Concat(physical, INSTALL_LOCK));

           Settings.TurnOffDebug();

           Cms.Init();

            // 重启
            HttpRuntime.UnloadAppDomain();
            //AppDomain.Unload(AppDomain.CurrentDomain);

            return InstallCode.SUCCESS;
        }
예제 #21
0
        public InstallCode Process(HttpContext context)
        {
            NameValueCollection form = context.Request.Form;
            string physical          = Cms.PyhicPath;

            if (!Directory.Exists(Cms.PyhicPath + "config"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "config").Create();
            }

            if (File.Exists(String.Concat(physical, INSTALL_LOCK)))
            {
                return(InstallCode.INSTALLED);
            }

            string licenceKey   = form["licence_key"].Trim(),
                   licenceName  = form["licence_name"].Trim(),
                   siteName     = form["site_name"].Trim(),
                   siteDomain   = form["site_domain"].Trim(),
                   siteLanguage = form["site_language"],
                   userName     = form["user_name"].Trim(),
                   userPwd      = form["user_pwd"].Trim(),
                   dbType       = form["db_type"].Trim(),
                   dbServer     = form["db_server"].Trim(),
                   dbPrefix     = form["db_prefix"].Trim(),
                   dbPrefix1    = form["db_prefix1"].Trim(),
                   dbName       = form["db_name"].Trim(),
                   dbUsr        = form["db_usr"].Trim(),
                   dbPwd        = form["db_pwd"].Trim(),
                   dbFile       = form["db_file"].Trim();

            string dbStr = "";

            #region 检测数据
            if (String.IsNullOrEmpty(licenceName) || String.IsNullOrEmpty(licenceKey))
            {
                return(InstallCode.NO_LICENCE);
            }
            if (String.IsNullOrEmpty(siteName))
            {
                return(InstallCode.NO_SITE_NAME);
            }

            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(userPwd))
            {
                return(InstallCode.NO_USER);
            }

            #endregion

            #region 初始化数据库设置

            //数据表前缀
            if (String.IsNullOrEmpty(dbPrefix))
            {
                dbPrefix = dbPrefix1;
            }

            const String dbDirName = "data";

            //移动Access或SQLite数据库
            if (dbType == "sqlite")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".db";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".db";
                }
                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }
                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else if (dbType == "oledb")
            {
                if (dbFile == "")
                {
                    dbFile = "rd_" + string.Empty.RandomLetters(5) + ".mdb";
                }
                else if (dbFile.IndexOf(".", StringComparison.Ordinal) == -1)
                {
                    dbFile += ".mdb";
                }

                if (!Directory.Exists(physical + dbDirName))
                {
                    Directory.CreateDirectory(physical + dbDirName).Create();
                }
                File.Copy(physical + FILE_DB_OLEDB, physical + dbDirName + "/" + dbFile, true);
                dbStr = "Data Source=$ROOT/" + dbDirName + "/" + dbFile;
            }
            else
            {
                //数据库资料不全
                if (String.IsNullOrEmpty(dbServer) || String.IsNullOrEmpty(dbUsr) || String.IsNullOrEmpty(dbName) || String.IsNullOrEmpty(dbPrefix))
                {
                    return(InstallCode.DB_ERROR);
                }

                if (dbType == "mysql")
                {
                    dbStr = String.Format("server={0};database={1};uid={2};pwd={3};charset=utf8", dbServer, dbName, dbUsr, dbPwd);
                }
                else if (dbType == "mssql")
                {
                    dbStr = String.Format("server={0};database={1};uid={2};pwd={3}", dbServer, dbName, dbUsr, dbPwd);
                }
                else
                {
                    return(InstallCode.DB_UNKNOWN);
                }
            }

            #endregion

            #region 写入配置

            if (File.Exists(physical + FILE_SETTING))
            {
                File.Delete(physical + FILE_SETTING);
            }
            SettingFile file = new SettingFile(physical + FILE_SETTING);
            file.Set("license_key", licenceKey);
            file.Set("license_name", licenceName);
            file.Set("server_static", "");
            file.Set("server_static_enabled", "false");

            file.Set("db_type", dbType);
            file.Set("db_conn", dbStr);
            file.Set("db_prefix", dbPrefix);

            file.Set("mm_avatar_path", "/file/avatar/");
            file.Flush();

            #endregion

            #region 初始化数据库

            if (!ExtraDB(dbType, dbStr, dbPrefix))
            {
                return(InstallCode.DB_INIT_ERROR);
            }

            #endregion

            #region 初始化数据

            //默认数据为:
            // cms_sites        siteid为1的站点
            // cms_category   默认的about分类
            // cms_usergroup


            //更新默认站点
            this.db.ExecuteNonQuery(new SqlQuery(
                                        String.Format("UPDATE {0}site SET domain=@domain,name=@name,tpl=@tpl,language=@language,seo_title=@name where site_id=1", dbPrefix),
                                        new object[, ] {
                { "@domain", siteDomain },
                { "@name", siteName },
                { "@tpl", "default" },
                { "@language", siteLanguage },
            }));

            //创建管理用户
            DateTime dt = DateTime.Now;
            this.db.ExecuteNonQuery(new SqlQuery(
                                        String.Format(@"INSERT INTO {0}user(name,avatar,phone,email, check_code,flag,create_time,last_login_time) 
                    VALUES(@name,@avatar,@phone,@email,@checkCode,@flag,@time,@time)", dbPrefix),
                                        new object[, ] {
                { "@name", "管理员" },
                { "@avatar", "/public/mui/css/latest/avatar.gif" },
                { "@phone", "" },
                { "@email", "" },
                { "@checkCode", "" },
                { "@flag", Role.Master.Flag },
                { "@time", dt },
            }));
            int userId = int.Parse(this.db.ExecuteScalar(String.Format("SELECT max(id) FROM {0}user", dbPrefix)).ToString());
            this.db.ExecuteNonQuery(new SqlQuery(
                                        String.Format(@"INSERT INTO {0}credential(user_id,user_name,password,enabled)VALUES(@userId,@userName,@password,1)", dbPrefix),
                                        new object[, ] {
                { "@userId", userId },
                { "@userName", userName },
                { "@password", Generator.Sha1Pwd(userPwd, Generator.Offset) },
            }));

            #endregion


            //创建安装文件
            File.Create(String.Concat(physical, INSTALL_LOCK));

            Settings.TurnOffDebug();

            Cms.Init(BootFlag.Normal, null);

            // 重启
            HttpRuntime.UnloadAppDomain();
            //AppDomain.Unload(AppDomain.CurrentDomain);

            return(InstallCode.SUCCESS);
        }
예제 #22
0
        public InstallCode Process(HttpContext context)
        {
            NameValueCollection form = context.Request.Form;
            string physical          = Cms.PyhicPath;

            if (!Directory.Exists(Cms.PyhicPath + "config"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "config").Create();
            }

            if (System.IO.File.Exists(String.Concat(physical, INSTALL_LOCK)))
            {
                return(InstallCode.Installed);
            }

            string t_key         = form["t_key"],
                   t_name        = form["t_name"],
                   site_name     = form["site_name"],
                   site_domain   = form["site_domain"],
                   site_language = form["site_language"],
                   user_name     = form["user_name"],
                   user_pwd      = form["user_pwd"],
                   db_type       = form["db_type"],
                   db_server     = form["db_server"],
                   db_prefix     = form["db_prefix"],
                   db_prefix1    = form["db_prefix1"],
                   db_name       = form["db_name"],
                   db_usr        = form["db_usr"],
                   db_pwd        = form["db_pwd"],
                   db_file       = form["db_file"];

            string db_str = "";

            #region 检测数据

            if (String.IsNullOrEmpty(user_name) || String.IsNullOrEmpty(user_pwd))
            {
                return(InstallCode.NO_USER);
            }

            #endregion

            #region 初始化数据库设置

            //数据表前缀
            if (String.IsNullOrEmpty(db_prefix))
            {
                db_prefix = db_prefix1;
            }


            //移动Access或SQLite数据库
            if (db_type == "sqlite")
            {
                if (db_file == "")
                {
                    db_file = "#db.db3";
                }
                else if (db_file.IndexOf(".") == -1)
                {
                    db_file += ".db3";
                }
                System.IO.File.Copy(physical + FILE_DB_SQLITE, physical + "data/" + db_file, true);
                db_str = "Data Source=$ROOT/data/" + db_file;
            }
            else if (db_type == "oledb")
            {
                if (db_file == "")
                {
                    db_file = "#db.mdb";
                }
                else if (db_file.IndexOf(".") == -1)
                {
                    db_file += ".mdb";
                }
                System.IO.File.Copy(physical + FILE_DB_OLEDB, physical + "data/" + db_file, true);
                db_str = "Data Source=$ROOT/data/" + db_file;
            }
            else
            {
                //数据库资料不全
                if (String.IsNullOrEmpty(db_server) || String.IsNullOrEmpty(db_usr) || String.IsNullOrEmpty(db_name) || String.IsNullOrEmpty(db_prefix))
                {
                    return(InstallCode.DB_ERROR);
                }

                if (db_type == "mysql")
                {
                    db_str = String.Format("server={0};database={1};uid={2};pwd={3};charset=utf8", db_server, db_name, db_usr, db_pwd);
                }
                else if (db_type == "mssql")
                {
                    db_str = String.Format("server={0};database={1};uid={2};pwd={3}", db_server, db_name, db_usr, db_pwd);
                }
                else
                {
                    return(InstallCode.DB_UNKNOWN);
                }
            }

            #endregion

            #region 写入配置

            if (System.IO.File.Exists(physical + FILE_SETTING))
            {
                System.IO.File.Delete(physical + FILE_SETTING);
            }
            SettingFile file = new SettingFile(physical + FILE_SETTING);
            file.Append("license_key", t_key);
            file.Append("license_name", t_name);
            file.Append("server_static", "");
            file.Append("server_static_enabled", "false");

            file.Append("db_type", db_type);
            file.Append("db_conn", db_str);
            file.Append("db_prefix", db_prefix);

            file.Append("mm_avatar_path", "/file/avatar/");
            file.Flush();

            #endregion

            #region 初始化数据库

            if (!ExtraDB(db_type, db_str, db_prefix))
            {
                return(InstallCode.DB_INIT_ERROR);
            }

            #endregion

            #region 初始化数据

            //默认数据为:
            // cms_sites        siteid为1的站点
            // cms_categories   默认的about分类
            // cms_usergroups


            //更新默认站点
            this.db.ExecuteNonQuery(new SqlQuery(
                                        String.Format("UPDATE {0}sites SET domain=@domain,name=@name,tpl=@tpl,seotitle=@name where siteid=1", db_prefix),
                                        new object[, ] {
                { "@domain", site_domain },
                { "@name", site_name },
                { "@tpl", "default" }
            }));

            //创建管理用户
            this.db.ExecuteNonQuery(new SqlQuery(
                                        String.Format(@"
                        INSERT INTO {0}users (
                        siteid ,
                        username ,
                        password ,
                        name ,
                        groupid ,
                        available ,
                        createdate ,
                        lastlogindate ) VALUES (0,@username,@password,@name,1,1,@dt,@dt)
                    ", db_prefix),
                                        new object[, ] {
                { "@username", user_name },
                { "@password", user_pwd.Encode16MD5().EncodeMD5() },
                { "@name", "管理员" },
                { "@dt", DateTime.Now }
            }));


            #endregion


            //创建安装文件
            System.IO.File.Create(String.Concat(physical, INSTALL_LOCK));

            Settings.TurnOffDebug();

            Cms.Init();

            // 重启
            HttpRuntime.UnloadAppDomain();
            //AppDomain.Unload(AppDomain.CurrentDomain);

            return(InstallCode.SUCCESS);
        }
예제 #23
0
        public void Save()
        {
            SettingFile sf = new SettingFile(String.Format("{0}templates/{1}/tpl.conf",Cms.PyhicPath,this.tplName));

            /**************** 模板设置 ****************/
             if (sf.Contains("CFG_ShowErrror"))
            {
                sf["CFG_ShowErrror"] = this.CFG_ShowError?"true":"false";
            }
            else
            {
            	sf.Append("CFG_ShowErrror", this.CFG_ShowError?"true":"false");
            }
            
            if (sf.Contains("CFG_SitemapSplit"))
            {
                sf["CFG_SitemapSplit"] = this.cfg_sitemapSplit;
            }
            else
            {
                sf.Append("CFG_SitemapSplit", this.cfg_sitemapSplit);
            }
            if (sf.Contains("CFG_ArchiveTagsFormat"))
            {
                sf["CFG_ArchiveTagsFormat"] = this.cfg_ArchiveTagsFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveTagsFormat", this.cfg_ArchiveTagsFormat);
            }
            if (sf.Contains("CFG_NavigatorLinkFormat"))
            {
                sf["CFG_NavigatorLinkFormat"] = this.cfg_navigatorLinkFormat;
            }
            else
            {
                sf.Append("CFG_NavigatorLinkFormat", this.cfg_navigatorLinkFormat);
            }
            if (sf.Contains("CFG_NavigatorChildFormat"))
            {
                sf["CFG_NavigatorChildFormat"] = this.cfg_navigatorChildFormat;
            }
            else
            {
                sf.Append("CFG_NavigatorChildFormat", this.cfg_navigatorChildFormat);
            }
            if (sf.Contains("CFG_FriendShowNum"))
            {
                sf["CFG_FriendShowNum"] = this.cfg_friendShowNum.ToString();
            }
            else
            {
                sf.Append("CFG_FriendShowNum", this.cfg_friendShowNum.ToString());
            }
            if (sf.Contains("CFG_FriendLinkFormat"))
            {
                sf["CFG_FriendLinkFormat"] = this.cfg_friendLinkFormat;
            }
            else
            {
                sf.Append("CFG_FriendLinkFormat", this.cfg_friendLinkFormat);
            }
            if (sf.Contains("CFG_TrafficFormat"))
            {
                sf["CFG_TrafficFormat"] = this.cfg_trafficFormat;
            }
            else
            {
                sf.Append("CFG_TrafficFormat", this.cfg_trafficFormat);
            }
            if (sf.Contains("CFG_CommentEditorHtml"))
            {
                sf["CFG_CommentEditorHtml"] = this.cfg_commentEditorHtml;
            }
            else
            {
                sf.Append("CFG_CommentEditorHtml", this.cfg_commentEditorHtml);
            }
            if (sf.Contains("CFG_allowAmousComment"))
            {
                sf["CFG_allowAmousComment"] = this.cfg_allowAmousComment ? "true" : "false";
            }
            else
            {
                sf.Append("CFG_allowAmousComment", this.cfg_allowAmousComment ? "true" : "false");
            }
            if (sf.Contains("CFG_OutlineLength"))
            {
                sf["CFG_OutlineLength"] = this.cfg_outlineLength.ToString();
            }
            else
            {
                sf.Append("CFG_OutlineLength", this.cfg_outlineLength.ToString());
            }
            if (sf.Contains("CFG_ArchiveFormat"))
            {
                sf["CFG_ArchiveFormat"] = this.cfg_archiveFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveFormat", this.cfg_archiveFormat);
            }
            if (sf.Contains("CFG_ArchiveLinkFormat"))
            {
                sf["CFG_ArchiveLinkFormat"] =this.cfg_archiveLinkFormat;
            }
            else
            {
                sf.Append("CFG_ArchiveLinkFormat", this.cfg_archiveLinkFormat);
            }
            if (sf.Contains("CFG_PrevArchiveFormat"))
            {
                sf["CFG_PrevArchiveFormat"] = this.cfg_prevArchiveFormat;
            }
            else
            {
                sf.Append("CFG_PrevArchiveFormat", this.cfg_prevArchiveFormat);
            }
            if (sf.Contains("CFG_NextArchiveFormat"))
            {
                sf["CFG_NextArchiveFormat"] = this.cfg_nextArchiveFormat;
            }
            else
            {
                sf.Append("CFG_NextArchiveFormat", this.cfg_nextArchiveFormat);
            }

            if (sf.Contains("CFG_CategoryLinkFormat"))
            {
                sf["CFG_CategoryLinkFormat"] = this.cfg_categoryLinkFormat;
            }
            else
            {
                sf.Append("CFG_CategoryLinkFormat", this.cfg_categoryLinkFormat);
            }
            sf.Flush();
        }