示例#1
0
文件: Core.cs 项目: moayyaed/Uber-CMS
 public static void cmsStop()
 {
     // Stop cycler
     cyclerStop();
     // Stop e-mail queue service
     emailQueue.stop();
     // Set the state
     state = State.Stopped;
     // Inform each plugin
     foreach (ResultRow plugin in globalConnector.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)Plugins.Base.State.Enabled + "' ORDER BY invoke_order ASC"))
     {
         try
         {
             Misc.Plugins.invokeMethod(plugin["classpath"], "cmsStop", new object[] { plugin["pluginid"], globalConnector });
         }
         catch
         { }
     }
     // Dispose the templates
     templates.dispose();
     templates = null;
     // Dispose settings
     settings.dispose();
     settings = null;
     // Dispose the global connector
     try
     {
         globalConnector.Disconnect();
     }
     finally
     {
         globalConnector = null;
     }
 }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check the templates are loaded, else load them
#if !DEBUG
        if (templates == null)
        {
            templates = new UberCMS.Misc.HtmlTemplates();
            templates.reloadFromDisk(AppDomain.CurrentDomain.BaseDirectory + "\\Installer\\Templates");
        }
#else
        if (templates == null)
        {
            templates = new UberCMS.Misc.HtmlTemplates();
        }
        templates.reloadFromDisk(AppDomain.CurrentDomain.BaseDirectory + "\\Installer\\Templates");
#endif
        // Check if any DB settings have been loaded, else load them
        if (dbSettings == null && File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\CMS.config"))
        {
            XmlDocument settings = new XmlDocument();
            settings.LoadXml(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\CMS.config"));
            dbSettings = new DbSettings(
                settings["settings"]["db"]["host"].InnerText,
                settings["settings"]["db"]["database"].InnerText,
                settings["settings"]["db"]["username"].InnerText,
                settings["settings"]["db"]["password"].InnerText,
                int.Parse(settings["settings"]["db"]["port"].InnerText)
                );
            settings = null;
        }
        // Invoke the correct page to handle the request
        UberCMS.Misc.PageElements pageElements = new UberCMS.Misc.PageElements();
        pageElements["URL"]      = ResolveUrl("/install");
        pageElements["BASE_URL"] = ResolveUrl("/");
        StringBuilder content = new StringBuilder();
#if !INSTALLED
        switch (Request.QueryString["1"])
        {
        case "home":
        case null:
            pageHome(ref pageElements, Request, Response, ref content);
            break;

        case "setup":
            pageSetup(ref pageElements, Request, Response, ref content);
            break;

        case "install":
            pageInstall(ref pageElements, Request, Response, ref content);
            break;
        }
#else
        Response.Redirect(ResolveUrl(""));
#endif
        // Build and display the final output
        pageElements["CONTENT"] = content.ToString();
        StringBuilder template = new StringBuilder(templates[TEMPLATES_KEY]["template"]);
        pageElements.replaceElements(ref template, 0, 5);
        Response.Write(template.ToString());
    }
示例#3
0
文件: Core.cs 项目: moayyaed/Uber-CMS
 public static void cmsStart()
 {
     try
     {
         // Set the base-path and check the CMS has been installed
         basePath = AppDomain.CurrentDomain.BaseDirectory;
         if (basePath.EndsWith("\\"))
         {
             basePath = basePath.Remove(basePath.Length - 1, 1);
         }
         if (!File.Exists(basePath + "\\CMS.config"))
         {
             state = State.NotInstalled;
             return;
         }
         // Load the connector settings
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(File.ReadAllText(basePath + "\\CMS.config"));
         connHost     = doc["settings"]["db"]["host"].InnerText;
         connPort     = int.Parse(doc["settings"]["db"]["port"].InnerText);
         connDatabase = doc["settings"]["db"]["database"].InnerText;
         connUsername = doc["settings"]["db"]["username"].InnerText;
         connPassword = doc["settings"]["db"]["password"].InnerText;
         // Set the global connector
         globalConnector = connectorCreate(true);
         // Load and start e-mail queue service
         if (doc["settings"]["mail"]["host"].InnerText.Length == 0 || doc["settings"]["mail"]["port"].InnerText.Length == 0 || doc["settings"]["mail"]["username"].InnerText.Length == 0 || doc["settings"]["mail"]["address"].InnerText.Length == 0)
         {
             // Create disabled e-mail queue
             emailQueue = new Misc.EmailQueue();
         }
         else
         {
             emailQueue = new Misc.EmailQueue(doc["settings"]["mail"]["host"].InnerText, int.Parse(doc["settings"]["mail"]["port"].InnerText), doc["settings"]["mail"]["username"].InnerText, doc["settings"]["mail"]["password"].InnerText, doc["settings"]["mail"]["address"].InnerText);
         }
         emailQueue.start();
         // Wipe the cache folder
         string cachePath = basePath + "\\Cache";
         if (Directory.Exists(cachePath))
         {
             // We don't just delete the directory because something could be in-use..hence we try to delete as much as possible
             try
             {
                 foreach (string file in Directory.GetFiles(cachePath, "*", SearchOption.AllDirectories))
                 {
                     File.Delete(file);
                 }
                 foreach (string dir in Directory.GetDirectories(cachePath, "*", SearchOption.AllDirectories))
                 {
                     Directory.Delete(dir);
                 }
             }
             catch
             {
             }
         }
         // Load settings
         settings = new Misc.Settings();
         settings.reload(globalConnector);
         // Load templates
         templates = new Misc.HtmlTemplates(globalConnector);
         // Invoke plugins
         foreach (ResultRow plugin in globalConnector.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)Plugins.Base.State.Enabled + "' ORDER BY invoke_order ASC"))
         {
             try
             {
                 Misc.Plugins.invokeMethod(plugin["classpath"], "cmsStart", new object[] { plugin["pluginid"], globalConnector });
             }
             catch
             { }
         }
         // Complete
         state = State.Started;
         // Begin cycler
         cyclerStart();
     }
     catch (Exception ex)
     {
         state = State.CriticalFailure;
         criticalFailureError = ex;
     }
 }