コード例 #1
0
        private static void UpgradeModule(EventMessage message)
        {
            try
            {
                int desktopModuleId = Convert.ToInt32(message.Attributes["DesktopModuleId"]);
                var desktopModule = DesktopModuleController.GetDesktopModule(desktopModuleId, Null.NullInteger);

                string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
                object controller = Reflection.CreateObject(BusinessControllerClass, "");
                if (controller is IUpgradeable)
                {
					//get the list of applicable versions
                    string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].Split(',');
                    foreach (string Version in UpgradeVersions)
                    {
						//call the IUpgradeable interface for the module/version
                        string Results = ((IUpgradeable) controller).UpgradeModule(Version);
                        //log the upgrade results
                        var log = new LogInfo {LogTypeKey = EventLogController.EventLogType.MODULE_UPDATED.ToString()};
                        log.AddProperty("Module Upgraded", BusinessControllerClass);
                        log.AddProperty("Version", Version);
                        if (!string.IsNullOrEmpty(Results))
                        {
                            log.AddProperty("Results", Results);
                        }
                        LogController.Instance.AddLog(log);
                    }
                }
                UpdateSupportedFeatures(controller, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
        }
コード例 #2
0
ファイル: SendMail.cs プロジェクト: MartyNZ/Events5-2sic
    public bool Send(
        string emailTemplateFilename,
        Dictionary <string, object> contactFormRequest,
        string MailFrom,
        string MailTo,
        string MailCC,
        string MailReply)
    {
        var mailEngine = CreateInstance("../../live/email-templates/" + emailTemplateFilename);
        var mailSubj   = mailEngine.Subject();
        var mailBody   = mailEngine.Message(contactFormRequest).ToString();

        // Send Mail
        // uses the DNN command: http://www.dnnsoftware.com/dnn-api/html/886d0ac8-45e8-6472-455a-a7adced60ada.htm
        var sendMailResult = Mail.SendMail(MailFrom, MailTo, MailCC, "", MailReply, MailPriority.Normal,
                                           mailSubj, MailFormat.Html, System.Text.Encoding.UTF8, mailBody, new string[0], "", "", "", "", false);

        // Log to DNN - just as a last resort in case something is lost, to track down why
        var logInfo = new DotNetNuke.Services.Log.EventLog.LogInfo
        {
            LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT.ToString()
        };

        logInfo.AddProperty("MailFrom", MailFrom);
        logInfo.AddProperty("MailTo", MailTo);
        logInfo.AddProperty("MailCC", MailCC);
        logInfo.AddProperty("MailReply", MailReply);
        logInfo.AddProperty("MailSubject", mailSubj);
        logInfo.AddProperty("SSL", DotNetNuke.Entities.Host.Host.EnableSMTPSSL.ToString());
        logInfo.AddProperty("Result", sendMailResult);
        DotNetNuke.Services.Log.EventLog.EventLogController.Instance.AddLog(logInfo);

        return(sendMailResult == "");
    }
コード例 #3
0
    public bool Send(
        string emailTemplateFilename,
        Dictionary <string, object> valuesWithMailLabels,
        string MailFrom,
        string MailTo,
        string MailCC,
        string MailReply,
        List <ToSic.Sxc.Adam.IFile> files)
    {
        // Log what's happening in case we run into problems
        var wrapLog = Log.Call("template:" + emailTemplateFilename + ", from:" + MailFrom + ", to:" + MailTo + ", cc:" + MailCC + ", reply:" + MailReply);

        // Check for attachments and add them to the mail
        var attachments = files.Select(f =>
                                       new System.Net.Mail.Attachment(
                                           new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/") + f.Url, FileMode.Open), f.FullName)).ToList();

        Log.Add("Get MailEngine");
        var mailEngine = CreateInstance("../../email-templates/" + emailTemplateFilename);
        var mailBody   = mailEngine.Message(valuesWithMailLabels).ToString();
        var mailSubj   = mailEngine.Subject(valuesWithMailLabels);

        // Send Mail
        // uses the DNN command: http://www.dnnsoftware.com/dnn-api/html/886d0ac8-45e8-6472-455a-a7adced60ada.htm
        Log.Add("sending...");
        var sendMailResult = Mail.SendMail(MailFrom, MailTo, MailCC, "", MailReply, MailPriority.Normal, mailSubj, MailFormat.Html, System.Text.Encoding.UTF8, mailBody, attachments, "", "", "", "", DotNetNuke.Entities.Host.Host.EnableSMTPSSL);

        // Log to DNN - just as a last resort in case something is lost, to track down why
        var logInfo = new DotNetNuke.Services.Log.EventLog.LogInfo
        {
            LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT.ToString()
        };

        logInfo.AddProperty("MailFrom", MailFrom);
        logInfo.AddProperty("MailTo", MailTo);
        logInfo.AddProperty("MailCC", MailCC);
        logInfo.AddProperty("MailReply", MailReply);
        logInfo.AddProperty("MailSubject", mailSubj);
        logInfo.AddProperty("SSL", DotNetNuke.Entities.Host.Host.EnableSMTPSSL.ToString());
        logInfo.AddProperty("Result", sendMailResult);
        DotNetNuke.Services.Log.EventLog.EventLogController.Instance.AddLog(logInfo);

        wrapLog("ok");
        return(sendMailResult == "");
    }
コード例 #4
0
        public static RewriterConfiguration GetConfig()
        {
            var config = new RewriterConfiguration {Rules = new RewriterRuleCollection()};
            FileStream fileReader = null;
            string filePath = "";
            try
            {
                config = (RewriterConfiguration) DataCache.GetCache("RewriterConfig");
                if ((config == null))
                {
                    filePath = Common.Utilities.Config.GetPathToFile(Common.Utilities.Config.ConfigFileType.SiteUrls);

                    //Create a FileStream for the Config file
                    fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    var doc = new XPathDocument(fileReader);
                    config = new RewriterConfiguration {Rules = new RewriterRuleCollection()};
                    foreach (XPathNavigator nav in doc.CreateNavigator().Select("RewriterConfig/Rules/RewriterRule"))
                    {
                        var rule = new RewriterRule {LookFor = nav.SelectSingleNode("LookFor").Value, SendTo = nav.SelectSingleNode("SendTo").Value};
                        config.Rules.Add(rule);
                    }
                    if (File.Exists(filePath))
                    {
						//Set back into Cache
                        DataCache.SetCache("RewriterConfig", config, new DNNCacheDependency(filePath));
                    }
                }
            }
            catch (Exception ex)
            {
				//log it
                var objEventLog = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("UrlRewriter.RewriterConfiguration", "GetConfig Failed");
                objEventLogInfo.AddProperty("FilePath", filePath);
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                Logger.Error(objEventLogInfo);

            }
            finally
            {
                if (fileReader != null)
                {
					//Close the Reader
                    fileReader.Close();
                }
            }
            return config;
        }
コード例 #5
0
        /// <summary>
        /// logs an exception related to a module provider once per cache-lifetime
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="status"></param>
        /// <param name="result"></param>
        /// <param name="messages"></param>
        /// <param name="provider"></param>
        public static void LogModuleProviderExceptionInRequest(Exception ex, string status,
                                                                ExtensionUrlProvider provider, 
                                                                UrlAction result,
                                                                List<string> messages)
        {
            if (ex != null)
            {
                string moduleProviderName = "Unknown Provider";
                string moduleProviderVersion = "Unknown Version";
                if (provider != null)
                {
                    moduleProviderName = provider.ProviderConfig.ProviderName;
                    moduleProviderVersion = provider.GetType().Assembly.GetName(false).Version.ToString();
                }
                //this logic prevents a site logging an exception for every request made.  Instead 
                //the exception will be logged once for the life of the cache / application restart or 1 hour, whichever is shorter.
                //create a cache key for this exception type
                string cacheKey = ex.GetType().ToString();
                //see if there is an existing object logged for this exception type
                object existingEx = DataCache.GetCache(cacheKey);
                if (existingEx == null)
                {
                    //if there was no existing object logged for this exception type, this is a new exception
                    DateTime expire = DateTime.Now.AddHours(1);
                    DataCache.SetCache(cacheKey, cacheKey, expire);
                    //just store the cache key - it doesn't really matter
                    //create a log event
                    string productVer = Assembly.GetExecutingAssembly().GetName(false).Version.ToString();
                    var elc = new EventLogController();
                    var logEntry = new LogInfo {LogTypeKey = "GENERAL_EXCEPTION"};
                    logEntry.AddProperty("Url Rewriting Extension Url Provider Exception",
                                         "Exception in Url Rewriting Process");
                    logEntry.AddProperty("Provider Name", moduleProviderName);
                    logEntry.AddProperty("Provider Version", moduleProviderVersion);
                    logEntry.AddProperty("Http Status", status);
                    logEntry.AddProperty("Product Version", productVer);
                    if (result != null)
                    {
                        logEntry.AddProperty("Original Path", result.OriginalPath ?? "null");
                        logEntry.AddProperty("Raw Url", result.RawUrl ?? "null");
                        logEntry.AddProperty("Final Url", result.FinalUrl ?? "null");

                        logEntry.AddProperty("Rewrite Result", !string.IsNullOrEmpty(result.RewritePath)
                                                                     ? result.RewritePath
                                                                     : "[no rewrite]");
                        logEntry.AddProperty("Redirect Location", string.IsNullOrEmpty(result.FinalUrl) 
                                                                    ? "[no redirect]" 
                                                                    : result.FinalUrl);
                        logEntry.AddProperty("Action", result.Action.ToString());
                        logEntry.AddProperty("Reason", result.Reason.ToString());
                        logEntry.AddProperty("Portal Id", result.PortalId.ToString());
                        logEntry.AddProperty("Tab Id", result.TabId.ToString());
                        logEntry.AddProperty("Http Alias", result.PortalAlias != null ? result.PortalAlias.HTTPAlias : "Null");

                        if (result.DebugMessages != null)
                        {
                            int i = 1;
                            foreach (string debugMessage in result.DebugMessages)
                            {
                                string msg = debugMessage;
                                if (debugMessage == null)
                                {
                                    msg = "[message was null]";
                                }
                                logEntry.AddProperty("Debug Message[result] " + i.ToString(), msg);
                                i++;
                            }
                        }
                    }
                    else
                    {
                        logEntry.AddProperty("Result", "Result value null");
                    }
                    if (messages != null)
                    {
                        int i = 1;
                        foreach (string msg in messages)
                        {
                            logEntry.AddProperty("Debug Message[raw] " + i.ToString(), msg);
                            i++;
                        }
                    }
                    logEntry.AddProperty("Exception Type", ex.GetType().ToString());
                    logEntry.AddProperty("Message", ex.Message);
                    logEntry.AddProperty("Stack Trace", ex.StackTrace);
                    if (ex.InnerException != null)
                    {
                        logEntry.AddProperty("Inner Exception Message", ex.InnerException.Message);
                        logEntry.AddProperty("Inner Exception Stacktrace", ex.InnerException.StackTrace);
                    }
                    logEntry.BypassBuffering = true;
                    elc.AddLog(logEntry);
                }
            }
        }
コード例 #6
0
        private void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            try
            {
                //First check if we are upgrading/installing or if it is a non-page request
                var app = (HttpApplication) sender;
                HttpRequest request = app.Request;

                //First check if we are upgrading/installing
                if (request.Url.LocalPath.ToLower().EndsWith("install.aspx")
                        || request.Url.LocalPath.ToLower().Contains("upgradewizard.aspx")
                        || request.Url.LocalPath.ToLower().Contains("installwizard.aspx"))
                {
                    return;
                }
				
                //exit if a request for a .net mapping that isn't a content page is made i.e. axd
                if (request.Url.LocalPath.ToLower().EndsWith(".aspx") == false && request.Url.LocalPath.ToLower().EndsWith(".asmx") == false &&
                    request.Url.LocalPath.ToLower().EndsWith(".ashx") == false)
                {
                    return;
                }
                if (HttpContext.Current != null)
                {
                    HttpContext context = HttpContext.Current;
                    if ((context == null))
                    {
                        return;
                    }
                    var page = context.Handler as CDefault;
                    if ((page == null))
                    {
                        return;
                    }
                    page.Load += OnPageLoad;
                }
            }
            catch (Exception ex)
            {
                var objEventLog = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("Analytics.AnalyticsModule", "OnPreRequestHandlerExecute");
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                Logger.Error(objEventLogInfo);

            }
        }
コード例 #7
0
ファイル: DnnRibbonBarTool.cs プロジェクト: biganth/Curt
 protected virtual void RestartApplication()
 {
     var objEv = new EventLogController();
     var objEventLogInfo = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
     objEventLogInfo.AddProperty("Message", GetString("UserRestart"));
     objEv.AddLog(objEventLogInfo);
     Config.Touch();
 }
コード例 #8
0
        public static void InvalidateDictionary(string reason, PageIndexData rebuildData, int portalId)
        {
            //if supplied, store the rebuildData for when the dictionary gets rebuilt
            //this is a way of storing data between dictionary rebuilds
            if (rebuildData != null)
            {
                DataCache.SetCache("rebuildData", rebuildData);
            }

            //add log entry for cache clearance
            var elc = new EventLogController();
            var logValue = new LogInfo { LogTypeKey = "HOST_ALERT" };
            try
            {
                //817 : not clearing items correctly from dictionary
                CacheController.FlushPageIndexFromCache();
            }
            catch (Exception ex)
            {
                //do nothing ; can be from trying to access cache after system restart
                Services.Exceptions.Exceptions.LogException(ex);
            }

            logValue.AddProperty("Url Rewriting Caching Message", "Page Index Cache Cleared.  Reason: " + reason);
            logValue.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString());
            elc.AddLog(logValue);
        }
コード例 #9
0
        /// <summary>
        /// cmdSendPassword_Click runs when the Password Reminder button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	03/21/2006  Created
        /// </history>
        protected void cmdSendPassword_Click( Object sender, EventArgs e )
        {
            string strMessage = Null.NullString;
            bool canSend = true;

            if( ( UseCaptcha && ctlCaptcha.IsValid ) || ( ! UseCaptcha ) )
            {
                if( txtUsername.Text.Trim() != "" )
                {
                    PortalSecurity objSecurity = new PortalSecurity();

                    UserInfo objUser = UserController.GetUserByName( PortalSettings.PortalId, txtUsername.Text, false );
                    if( objUser != null )
                    {
                        if( MembershipProviderConfig.PasswordRetrievalEnabled )
                        {
                            try
                            {
                                objUser.Membership.Password = UserController.GetPassword( ref objUser, txtAnswer.Text );
                            }
                            catch( Exception )
                            {
                                canSend = false;
                                strMessage = Localization.GetString( "PasswordRetrievalError", this.LocalResourceFile );
                            }
                        }
                        else
                        {
                            canSend = false;
                            strMessage = Localization.GetString( "PasswordRetrievalDisabled", this.LocalResourceFile );
                        }
                        if( canSend )
                        {
                            try
                            {
                                Mail.SendMail( objUser, MessageType.PasswordReminder, PortalSettings );
                                strMessage = Localization.GetString( "PasswordSent", this.LocalResourceFile );
                            }
                            catch( Exception )
                            {
                                canSend = false;
                            }
                        }
                    }
                    else
                    {
                        strMessage = Localization.GetString( "UsernameError", this.LocalResourceFile );
                        canSend = false;
                    }

                    if( canSend )
                    {
                        EventLogController objEventLog = new EventLogController();
                        LogInfo objEventLogInfo = new LogInfo();
                        objEventLogInfo.AddProperty( "IP", ipAddress );
                        objEventLogInfo.LogPortalID = PortalSettings.PortalId;
                        objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                        objEventLogInfo.LogUserID = UserId;
                        objEventLogInfo.LogUserName = objSecurity.InputFilter( txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup );
                        objEventLogInfo.LogTypeKey = "PASSWORD_SENT_SUCCESS";
                        objEventLog.AddLog( objEventLogInfo );

                        UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.GreenSuccess );
                    }
                    else
                    {
                        EventLogController objEventLog = new EventLogController();
                        LogInfo objEventLogInfo = new LogInfo();
                        objEventLogInfo.AddProperty( "IP", ipAddress );
                        objEventLogInfo.LogPortalID = PortalSettings.PortalId;
                        objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                        objEventLogInfo.LogUserID = UserId;
                        objEventLogInfo.LogUserName = objSecurity.InputFilter( txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup );
                        objEventLogInfo.LogTypeKey = "PASSWORD_SENT_FAILURE";
                        objEventLog.AddLog( objEventLogInfo );

                        UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
                    }
                }
                else
                {
                    strMessage = Localization.GetString( "EnterUsername", this.LocalResourceFile );
                    UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// logs an exception once per cache-lifetime
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="status"></param>
        /// <param name="result"></param>
        public static void LogExceptionInRequest(Exception ex, string status, UrlAction result)
        {
            if (ex != null)
            {
                //831 : improve exception logging by logging custom properties instead of just the raw exception
                //this logic prevents a site logging an exception for every request made.  Instead 
                //the exception will be logged once for the life of the cache / application restart or 1 hour, whichever is shorter.
                //create a cache key for this exception type
                string cacheKey = ex.GetType().ToString();
                //see if there is an existing object logged for this exception type
                object existingEx = DataCache.GetCache(cacheKey);
                if (existingEx == null)
                {
                    //if there was no existing object logged for this exception type, this is a new exception
                    DateTime expire = DateTime.Now.AddHours(1);
                    DataCache.SetCache(cacheKey, cacheKey, expire);
                    //just store the cache key - it doesn't really matter
                    //create a log event
                    var elc = new EventLogController();
                    var logEntry = new LogInfo { LogTypeKey = "GENERAL_EXCEPTION" };
                    logEntry.AddProperty("Url Processing Exception", "Exception in Url Rewriting Process");
                    logEntry.AddProperty("Http Status", status);
                    if (result != null)
                    {
                        logEntry.AddProperty("Original Path", result.OriginalPath ?? "null");
                        logEntry.AddProperty("Raw Url", result.RawUrl ?? "null");
                        logEntry.AddProperty("Final Url", result.FinalUrl ?? "null");

                        logEntry.AddProperty("Rewrite Result", !string.IsNullOrEmpty(result.RewritePath)
                                                                     ? result.RewritePath
                                                                     : "[no rewrite]");
                        logEntry.AddProperty("Redirect Location", string.IsNullOrEmpty(result.FinalUrl)
                                                                    ? "[no redirect]"
                                                                    : result.FinalUrl);
                        logEntry.AddProperty("Action", result.Action.ToString());
                        logEntry.AddProperty("Reason", result.Reason.ToString());
                        logEntry.AddProperty("Portal Id", result.PortalId.ToString());
                        logEntry.AddProperty("Tab Id", result.TabId.ToString());
                        logEntry.AddProperty("Http Alias", result.PortalAlias != null
                                                                ? result.PortalAlias.HTTPAlias
                                                                : "Null");

                        if (result.DebugMessages != null)
                        {
                            int i = 1;
                            foreach (string msg in result.DebugMessages)
                            {
                                logEntry.AddProperty("Debug Message " + i.ToString(), msg);
                                i++;
                            }
                        }
                    }
                    else
                    {
                        logEntry.AddProperty("Result", "Result value null");
                    }
                    logEntry.AddProperty("Exception Type", ex.GetType().ToString());
                    logEntry.AddProperty("Message", ex.Message);
                    logEntry.AddProperty("Stack Trace", ex.StackTrace);
                    if (ex.InnerException != null)
                    {
                        logEntry.AddProperty("Inner Exception Message", ex.InnerException.Message);
                        logEntry.AddProperty("Inner Exception Stacktrace", ex.InnerException.StackTrace);
                    }
                    logEntry.BypassBuffering = true;
                    elc.AddLog(logEntry);

                    //Log this error in lig4net
                    Logger.Error(ex);
                }
            }
        }
コード例 #11
0
		/// <summary>
		/// Processes the messages.
		/// </summary>
		/// <param name="eventMessages">The event messages.</param>
		/// <returns></returns>
        public static bool ProcessMessages(EventMessageCollection eventMessages)
        {
            bool success = Null.NullBoolean;
            EventMessage message;
            for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
            {
                message = eventMessages[messageNo];
                try
                {
                    object oMessageProcessor = Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
                    if (!((EventMessageProcessorBase) oMessageProcessor).ProcessMessage(message))
                    {
                        throw new Exception();
                    }
					
                    //Set Message comlete so it is not run a second time
                    DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);

                    success = true;
                }
                catch
                {
					//log if message could not be processed
                    var objEventLog = new EventLogController();
                    var objEventLogInfo = new LogInfo();
                    objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
                    objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
                    objEventLogInfo.AddProperty("Body", message.Body);
                    objEventLogInfo.AddProperty("Sender", message.Sender);
                    foreach (string key in message.Attributes.Keys)
                    {
                        objEventLogInfo.AddProperty(key, message.Attributes[key]);
                    }
                    if (!String.IsNullOrEmpty(message.ExceptionMessage))
                    {
                        objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
                    }
                    objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                    objEventLog.AddLog(objEventLogInfo);
                    if (message.ExpirationDate < DateTime.Now)
                    {
						//Set Message comlete so it is not run a second time
                        DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
                    }
                }
            }
            return success;
        }
コード例 #12
0
 protected virtual void RestartApplication()
 {
     var log = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
     log.AddProperty("Message", GetString("UserRestart"));
     LogController.Instance.AddLog(log);
     Config.Touch();
 }
コード例 #13
0
        private LogInfoArray GetLogFromXPath( string xpath, string PortalID, string LogType, int PageSize, int PageIndex, ref int TotalRecords )
        {
            XmlDocument xmlConfigDoc = GetConfigDoc();
            ArrayList arrLogFiles = GetLogFiles( xmlConfigDoc, PortalID, LogType );

            XmlDocument xmlLogFiles = new XmlDocument();
            xmlLogFiles.LoadXml( "<LogCollection></LogCollection>" );

            XmlElement xmlLogFilesDocEl;
            xmlLogFilesDocEl = xmlLogFiles.DocumentElement;

            ArrayList arrLogInfo = new ArrayList();

            int i;
            for( i = 0; i <= arrLogFiles.Count - 1; i++ )
            {
                bool FileIsCorrupt = false;
                bool FileExists = true;
                string LogFile;
                LogFile = Convert.ToString( arrLogFiles[i] );
                XmlDocument xmlLogFile = new XmlDocument();
                try
                {
                    lockLog.AcquireReaderLock( ReaderLockTimeout );
                    xmlLogFile.Load( LogFile );
                }
                catch( FileNotFoundException )
                {
                    FileExists = false;
                    //file doesn't exist
                }
                catch( XmlException )
                {
                    FileExists = false;
                    FileIsCorrupt = true;
                    //file is corrupt
                }
                finally
                {
                    lockLog.ReleaseReaderLock();
                }
                if( FileIsCorrupt )
                {
                    string s = "A log file is corrupt '" + LogFile + "'.";
                    if (LogFile.IndexOf( "Exceptions.xml.resources", 0) > 0)
                    {
                        s += "  This could be due to an older exception log file being written to by the new logging provider.  Try removing 'Exceptions.xml.resources' from the logs directory to solve the problem.";
                    }
                    LogInfo objEventLogInfo = new LogInfo();
                    objEventLogInfo.AddProperty( "Note", s );
                    objEventLogInfo.BypassBuffering = true;
                    objEventLogInfo.LogTypeKey = "HOST_ALERT";
                    EventLogController objEventLog = new EventLogController();
                    objEventLog.AddLog( objEventLogInfo );
                }
                else if( FileExists )
                {
                    XmlNodeList xmlNodes;
                    xmlNodes = xmlLogFile.SelectNodes( xpath );

                    XmlElement xmlLogNodes;
                    xmlLogNodes = xmlLogFiles.CreateElement( "logs" );

                    XmlNode xmlNode;
                    foreach( XmlNode tempLoopVar_xmlNode in xmlNodes )
                    {
                        xmlNode = tempLoopVar_xmlNode;
                        xmlLogNodes.AppendChild( xmlLogFiles.ImportNode( xmlNode, true ) );
                    }

                    xmlLogFilesDocEl.AppendChild( xmlLogNodes );
                }
            }

            return GetLogInfoFromXML( xmlLogFiles, PageSize, PageIndex, ref TotalRecords );
        }
コード例 #14
0
        //--------------------------------------------------------------
        //Method to send email notifications
        //--------------------------------------------------------------
        public override void SendLogNotifications()
        {
            try
            {
                lockNotif.AcquireWriterLock( WriterLockTimeout );
                XmlDocument xmlPendingNotificationsDoc = new XmlDocument();
                try
                {
                    xmlPendingNotificationsDoc.Load( GetFilePath( PendingNotificationsFile ) );
                }
                catch( FileNotFoundException )
                {
                    //file not found
                    return;
                }

                ArrayList arrLogTypeInfo;
                XMLLoggingProvider x = new XMLLoggingProvider();
                arrLogTypeInfo = x.GetLogTypeConfigInfo();

                PurgeLogBuffer();

                int a;
                for( a = 0; a <= arrLogTypeInfo.Count - 1; a++ )
                {
                    LogTypeConfigInfo objLogTypeInfo;
                    objLogTypeInfo = (LogTypeConfigInfo)arrLogTypeInfo[a];

                    if( objLogTypeInfo.EmailNotificationIsActive )
                    {
                        XmlNodeList xmlPendingNotifications = xmlPendingNotificationsDoc.DocumentElement.SelectNodes( "log[@NotificationLogTypeKey='" + objLogTypeInfo.LogTypeKey + "' and @LogTypePortalID='" + objLogTypeInfo.LogTypePortalID + "' and number(@LogCreateDateNum) > " + DateToNum( objLogTypeInfo.StartDateTime ).ToString() + "]" );

                        if( xmlPendingNotifications.Count >= objLogTypeInfo.NotificationThreshold )
                        {
                            //we have notifications to send out
                            XmlNode xmlPendingNotification;
                            XmlDocument xmlOut = new XmlDocument();
                            xmlOut.LoadXml( "<notification></notification>" );
                            foreach( XmlNode tempLoopVar_xmlPendingNotification in xmlPendingNotifications )
                            {
                                xmlPendingNotification = tempLoopVar_xmlPendingNotification;

                                XmlNode tmpNode;
                                tmpNode = xmlOut.ImportNode( xmlPendingNotification, true );
                                xmlOut.DocumentElement.AppendChild( tmpNode );

                                //Remove the node from the list of pending notifications
                                xmlPendingNotificationsDoc.DocumentElement.RemoveChild( xmlPendingNotification );
                            }

                            bool NotificationFailed = false;
                            string errSendNotif;

                            errSendNotif = Mail.Mail.SendMail( objLogTypeInfo.MailFromAddress, objLogTypeInfo.MailToAddress, "", "Log Notification", xmlOut.OuterXml, "", "", "", "", "", "" );

                            if( !String.IsNullOrEmpty(errSendNotif) )
                            {
                                //notification failed to send
                                NotificationFailed = true;
                            }

                            EventLogController objEventLogController = new EventLogController();
                            if( NotificationFailed )
                            {
                                //Notification failed, log it
                                LogInfo objEventLogInfo = new LogInfo();
                                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.LOG_NOTIFICATION_FAILURE.ToString();
                                objEventLogInfo.AddProperty( "Log Notification Failed: ", errSendNotif );
                                objEventLogController.AddLog( objEventLogInfo );

                                //need to reload the xml doc because
                                //we removed xml nodes above
                                xmlPendingNotificationsDoc.Load( GetFilePath( PendingNotificationsFile ) );

                                if( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] == null )
                                {
                                    XmlAttribute xmlNotificationFailed;
                                    xmlNotificationFailed = xmlPendingNotificationsDoc.CreateAttribute( "LastNotificationFailure" );
                                    xmlNotificationFailed.Value = DateTime.Now.ToString();
                                    xmlPendingNotificationsDoc.DocumentElement.Attributes.Append( xmlNotificationFailed );
                                }
                                else
                                {
                                    xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"].Value = DateTime.Now.ToString();
                                }
                                xmlPendingNotificationsDoc.Save( GetFilePath( PendingNotificationsFile ) );
                            }
                            else
                            {
                                //Notification succeeded.
                                //Save the updated pending notifications file
                                //so we remove the notifications that have been completed.
                                if( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] != null )
                                {
                                    xmlPendingNotificationsDoc.DocumentElement.Attributes.Remove( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] );
                                }

                                if( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationSuccess"] == null )
                                {
                                    XmlAttribute xmlNotificationSucceeded;
                                    xmlNotificationSucceeded = xmlPendingNotificationsDoc.CreateAttribute( "LastNotificationSuccess" );
                                    xmlNotificationSucceeded.Value = DateTime.Now.ToString();
                                    xmlPendingNotificationsDoc.DocumentElement.Attributes.Append( xmlNotificationSucceeded );
                                }
                                else
                                {
                                    xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationSuccess"].Value = DateTime.Now.ToString();
                                }
                                xmlPendingNotificationsDoc.Save( GetFilePath( PendingNotificationsFile ) );
                            }
                        }
                    }
                }

                x.DeleteOldPendingNotifications();
            }
            catch( Exception exc )
            {
                Exceptions.Exceptions.LogException( exc );
            }
            finally
            {
                lockNotif.ReleaseWriterLock();
            }
        }
コード例 #15
0
        private static void AddEventLog(int portalId, string username, int userId, string portalName, string ip, UserLoginStatus loginStatus)
        {
            var objEventLog = new EventLogController();

            //initialize log record
            var objEventLogInfo = new LogInfo();
            var objSecurity = new PortalSecurity();
            objEventLogInfo.AddProperty("IP", ip);
            objEventLogInfo.LogPortalID = portalId;
            objEventLogInfo.LogPortalName = portalName;
            objEventLogInfo.LogUserName = objSecurity.InputFilter(username, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
            objEventLogInfo.LogUserID = userId;

            //create log record
            objEventLogInfo.LogTypeKey = loginStatus.ToString();
            objEventLog.AddLog(objEventLogInfo);
        }
コード例 #16
0
ファイル: Upgrade.cs プロジェクト: VegasoftTI/Dnn.Platform
        ///-----------------------------------------------------------------------------
        ///<summary>
        ///  UpgradeApplication - This overload is used for general application upgrade operations.
        ///</summary>
        ///<remarks>
        ///  Since it is not version specific and is invoked whenever the application is
        ///  restarted, the operations must be re-executable.
        ///</remarks>
        ///<history>
        ///  [cnurse]	11/6/2004	documented
        ///  [cnurse] 02/27/2007 made public so it can be called from Wizard
        ///</history>
        ///-----------------------------------------------------------------------------
        public static void UpgradeApplication()
        {
            try
            {
                //Remove UpdatePanel from Login Control - not neccessary in popup.
                var loginControl = ModuleControlController.GetModuleControlByControlKey("Login", -1);
                loginControl.SupportsPartialRendering = false;

                ModuleControlController.SaveModuleControl(loginControl, true);

                //Upgrade to .NET 3.5/4.0
                TryUpgradeNETFramework();

                //Update the version of the client resources - so the cache is cleared
                DataCache.ClearHostCache(false);
                HostController.Instance.IncrementCrmVersion(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                var log = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(),
                    BypassBuffering = true
                };
                log.AddProperty("Upgraded DotNetNuke", "General");
                log.AddProperty("Warnings", "Error: " + ex.Message + Environment.NewLine);
                LogController.Instance.AddLog(log);
                try
                {
                    Exceptions.Exceptions.LogException(ex);
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);
                }

            }

            //Remove any .txt and .config files that may exist in the Install folder
            foreach (string file in Directory.GetFiles(Globals.InstallMapPath + "Cleanup\\", "??.??.??.txt"))
            {
                FileSystemUtils.DeleteFile(file);
            }
            foreach (string file in Directory.GetFiles(Globals.InstallMapPath + "Config\\", "??.??.??.config"))
            {
                FileSystemUtils.DeleteFile(file);
            }
        }
コード例 #17
0
        private void LogResult(string message)
        {
            var portalSecurity = new PortalSecurity();

            var objEventLog = new EventLogController();
            var objEventLogInfo = new LogInfo();
            
            objEventLogInfo.AddProperty("IP", _ipAddress);
            objEventLogInfo.LogPortalID = PortalSettings.PortalId;
            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
            objEventLogInfo.LogUserID = UserId;
        //    objEventLogInfo.LogUserName = portalSecurity.InputFilter(txtUsername.Text,
          //                                                           PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
            if (string.IsNullOrEmpty(message))
            {
                objEventLogInfo.LogTypeKey = "PASSWORD_SENT_SUCCESS";
            }
            else
            {
                objEventLogInfo.LogTypeKey = "PASSWORD_SENT_FAILURE";
                objEventLogInfo.LogProperties.Add(new LogDetailInfo("Cause", message));
            }
            
            objEventLog.AddLog(objEventLogInfo);
        }
コード例 #18
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Retrieves the Google Analytics config file, "SiteAnalytics.config".
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///   [vnguyen]   10/08/2010   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private StreamReader GetConfigFile()
        {
            StreamReader fileReader = null;
            string filePath = "";
            try
            {
                filePath = Globals.ApplicationMapPath + "\\SiteAnalytics.config";

                if (File.Exists(filePath))
                {
                    fileReader = new StreamReader(filePath);
                }
            }
            catch (Exception ex)
            {
                //log it
                var objEventLog = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("GoogleAnalytics.UpgradeModule", "GetConfigFile Failed");
                objEventLogInfo.AddProperty("FilePath", filePath);
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                fileReader.Close();
                Logger.Error(ex);

            }

            return fileReader;
        }
コード例 #19
0
        private void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            try
            {
                //First check if we are upgrading/installing or if it is a non-page request
                var app = (HttpApplication) sender;
                HttpRequest request = app.Request;

                if (!Initialize.ProcessHttpModule(request, false, false))
                {
                    return;
                }

                if (HttpContext.Current != null)
                {
                    HttpContext context = HttpContext.Current;
                    if ((context == null))
                    {
                        return;
                    }
                    var page = context.Handler as CDefault;
                    if ((page == null))
                    {
                        return;
                    }
                    page.Load += OnPageLoad;
                }
            }
            catch (Exception ex)
            {
                var log = new LogInfo {LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()};
                log.AddProperty("Analytics.AnalyticsModule", "OnPreRequestHandlerExecute");
                log.AddProperty("ExceptionMessage", ex.Message);
                LogController.Instance.AddLog(log);
                Logger.Error(log);

            }
        }
コード例 #20
0
        private void LogResult(string message)
        {
            var log = new LogInfo
            {
                LogPortalID = PortalSettings.PortalId,
                LogPortalName = PortalSettings.PortalName,
                LogUserID = UserId
            };

            if (string.IsNullOrEmpty(message))
            {
                log.LogTypeKey = "PASSWORD_SENT_SUCCESS";
            }
            else
            {
                log.LogTypeKey = "PASSWORD_SENT_FAILURE";
                log.LogProperties.Add(new LogDetailInfo("Cause", message));
            }
            log.AddProperty("IP", _ipAddress);
            
            LogController.Instance.AddLog(log);
        }
コード例 #21
0
        public void AuthenticationLogon()
        {
            Configuration configuration = Configuration.GetConfig();

            UserController authUserController = new UserController();
            string authCookies = Configuration.AUTHENTICATION_KEY + "_" + _portalSettings.PortalId;
            string LoggedOnUserName = HttpContext.Current.Request.ServerVariables[Configuration.LOGON_USER_VARIABLE];
            // HACK : Modified to not error if object is null.
            //if( LoggedOnUserName.Length > 0 )
            if (!String.IsNullOrEmpty(LoggedOnUserName))
            {
                UserInfo authUser;

                int intUserId = 0;

                Entities.Users.UserInfo dnnUser = Entities.Users.UserController.GetUserByName( _portalSettings.PortalId, LoggedOnUserName, false );

                if( dnnUser != null )
                {
                    intUserId = dnnUser.UserID;

                    // Synchronize role membership if it's required in settings
                    if( configuration.SynchronizeRole )
                    {
                        authUser = authUserController.GetUser( LoggedOnUserName );

                        // user object might be in simple version in none active directory network
                        if( authUser.GUID.Length != 0 )
                        {
                            authUser.UserID = intUserId;
                            UserController.AddUserRoles( _portalSettings.PortalId, authUser );
                        }
                    }
                }
                else
                {
                    // User not exists in DNN database, obtain user info from provider to add new
                    authUser = authUserController.GetUser( LoggedOnUserName );
                    if( authUser != null )
                    {
                        authUserController.AddDNNUser( authUser );
                        intUserId = authUser.UserID;
                        SetStatus( _portalSettings.PortalId, AuthenticationStatus.WinLogon );
                    }
                }

                if( intUserId > 0 )
                {
                    FormsAuthentication.SetAuthCookie( Convert.ToString( LoggedOnUserName ), true );

                    //check if user has supplied custom value for expiration
                    int PersistentCookieTimeout = 0;
                    if (Config.GetSetting("PersistentCookieTimeout") != null)
                    {
                        PersistentCookieTimeout = int.Parse(Config.GetSetting("PersistentCookieTimeout"));
                        //only use if non-zero, otherwise leave as asp.net value
                        if (PersistentCookieTimeout != 0)
                        {
                            //locate and update cookie
                            string authCookie = FormsAuthentication.FormsCookieName;
                            foreach (string cookie in HttpContext.Current.Response.Cookies)
                            {
                                if (cookie.Equals(authCookie))
                                {
                                    HttpContext.Current.Response.Cookies[cookie].Expires = DateTime.Now.AddMinutes(PersistentCookieTimeout);
                                }
                            }
                        }
                    }

                    SetStatus( _portalSettings.PortalId, AuthenticationStatus.WinLogon );

                    // Get ipAddress for eventLog
                    string ipAddress = "";
                    if( HttpContext.Current.Request.UserHostAddress != null )
                    {
                        ipAddress = HttpContext.Current.Request.UserHostAddress;
                    }

                    EventLogController eventLog = new EventLogController();
                    LogInfo eventLogInfo = new LogInfo();
                    eventLogInfo.AddProperty( "IP", ipAddress );
                    eventLogInfo.LogPortalID = _portalSettings.PortalId;
                    eventLogInfo.LogPortalName = _portalSettings.PortalName;
                    eventLogInfo.LogUserID = intUserId;
                    eventLogInfo.LogUserName = LoggedOnUserName;
                    eventLogInfo.AddProperty( "WindowsAuthentication", "True" );
                    eventLogInfo.LogTypeKey = "LOGIN_SUCCESS";

                    eventLog.AddLog( eventLogInfo );
                }
            }
            else
            {
                // Not Windows Authentication
            }

            // params "logon=windows" does nothing, just to force page to be refreshed
            string strURL = Globals.NavigateURL( _portalSettings.ActiveTab.TabID, "", "logon=windows" );
            HttpContext.Current.Response.Redirect( strURL, true );
        }
コード例 #22
0
        public HttpResponseMessage RecycleApplicationPool()
        {
            if (UserController.GetCurrentUserInfo().IsSuperUser)
            {
                var objEv = new EventLogController();
                var objEventLogInfo = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
                objEventLogInfo.AddProperty("Message", "UserRestart");
                objEv.AddLog(objEventLogInfo);
                Config.Touch();
                return Request.CreateResponse(HttpStatusCode.OK);
            }

            return Request.CreateResponse(HttpStatusCode.InternalServerError);
        }
コード例 #23
0
        private static void AddToTabDict(SharedDictionary<string, string> tabIndex,
                                            Dictionary<string, DupKeyCheck> dupCheckDict,
                                            string httpAlias,
                                            string tabPath,
                                            string rewrittenPath,
                                            int tabId,
                                            UrlEnums.TabKeyPreference keyDupAction,
                                            ref int tabPathDepth,
                                            bool checkForDupUrls,
                                            bool isDeleted)
        {
            //remove leading '/' and convert to lower for all keys 
            string tabPathSimple = tabPath.Replace("//", "/").ToLower();
            //the tabpath depth is only set if it's higher than the running highest tab path depth
            int thisTabPathDepth = tabPathSimple.Length - tabPathSimple.Replace("/", "").Length;
            if (thisTabPathDepth > tabPathDepth)
            {
                tabPathDepth = thisTabPathDepth;
            }
            if ((tabPathSimple.Length > 0 && tabPathSimple[0] == '/'))
            {
                tabPathSimple = tabPathSimple.Substring(1);
            }

            //Contruct the tab key for the dictionary. Using :: allows for separation of portal alias and tab path. 
            string tabKey = (httpAlias + "::" + tabPathSimple).ToLower();

            //construct the duplicate key check
            string dupKey = (httpAlias + "/" + tabPathSimple).ToLower();
            if (dupKey[dupKey.Length - 1] != '/')
            {
                dupKey += "/";
            }

            //now make sure there is NEVER a duplicate key exception by testing for existence first
            using (tabIndex.GetWriteLock())
            {
                if (tabIndex.ContainsKey(tabKey))
                {
                    //it's possible for a tab to be deleted and the tab path repeated. 
                    //the dictionary must be checked to ascertain whether the existing tab 
                    //should be replaced or not.  If the action is 'TabOK' it means
                    //replace the entry regardless.  If the action is 'TabRedirected' it means
                    //replace the existing dictionary ONLY if the existing dictionary entry is a 
                    //deleted tab.
                    bool replaceTab = (keyDupAction == UrlEnums.TabKeyPreference.TabOK); //default, replace the tab
                    if (replaceTab == false)
                    {
                        //ok, the tab to be added is either a redirected or deleted tab
                        //get the existing entry
                        //775 : don't assume that the duplicate check dictionary has the key
                        if (dupCheckDict.ContainsKey(dupKey))
                        {
                            DupKeyCheck foundTab = dupCheckDict[dupKey];
                            //a redirected tab will replace a deleted tab
                            if (foundTab.IsDeleted && keyDupAction == UrlEnums.TabKeyPreference.TabRedirected)
                            {
                                replaceTab = true;
                            }
                            if (foundTab.TabIdOriginal == "-1")
                            {
                                replaceTab = true;
                            }
                        }
                    }
                    if (replaceTab && !isDeleted) //don't replace if the incoming tab is deleted
                    {
                        //remove the previous one 
                        tabIndex.Remove(tabKey);
                        //add the new one 
                        tabIndex.Add(tabKey, Globals.glbDefaultPage + rewrittenPath);
                    }
                }
                else
                {
                    //just add the tabkey into the dictionary
                    tabIndex.Add(tabKey, Globals.glbDefaultPage + rewrittenPath);
                }
            }

            //checking for duplicates means throwing an exception when one is found, but this is just logged to the event log
            if (dupCheckDict.ContainsKey(dupKey))
            {
                DupKeyCheck foundTAb = dupCheckDict[dupKey];
                if ((foundTAb.IsDeleted == false && isDeleted == false) //found is not deleted, this tab is not deleted
                    && keyDupAction == UrlEnums.TabKeyPreference.TabOK
                    && foundTAb.TabIdOriginal != "-1")
                //-1 tabs are login, register, privacy etc
                {
                    //check whether to log for this or not
                    if (checkForDupUrls && foundTAb.TabIdOriginal != tabId.ToString())
                    //dont' show message for where same tab is being added twice)
                    {
                        //there is a naming conflict where this alias/tab path could be mistaken 
                        int tabIdOriginal;
                        string tab1Name = "", tab2Name = "";
                        if (int.TryParse(foundTAb.TabIdOriginal, out tabIdOriginal))
                        {
                            Dictionary<int, int> portalDic = PortalController.GetPortalDictionary();
                            int portalId = -1;
                            if (portalDic != null && portalDic.ContainsKey(tabId))
                            {
                                portalId = portalDic[tabId];
                            }

                            var tc = new TabController();
                            TabInfo tab1 = tc.GetTab(tabIdOriginal, portalId, false);
                            TabInfo tab2 = tc.GetTab(tabId, portalId, false);
                            if (tab1 != null)
                            {
                                tab1Name = tab1.TabName + " [" + tab1.TabPath + "]";
                            }
                            if (tab2 != null)
                            {
                                tab2Name = tab2.TabName + " [" + tab2.TabPath + "]";
                            }
                        }

                        string msg = "Page naming conflict. Url of (" + foundTAb.TabPath +
                                     ") resolves to two separate pages (" + tab1Name + " [tabid = " +
                                     foundTAb.TabIdOriginal + "], " + tab2Name + " [tabid = " + tabId.ToString() +
                                     "]). Only the second page will be shown for the url.";
                        const string msg2 = "PLEASE NOTE : this is an information message only, this message does not affect site operations in any way.";

                        //771 : change to admin alert instead of exception
                        var elc = new EventLogController();
                        //log a host alert
                        var logValue = new LogInfo { LogTypeKey = "HOST_ALERT" };
                        logValue.AddProperty("Advanced Friendly URL Provider Duplicate URL Warning", "Page Naming Conflict");
                        logValue.AddProperty("Duplicate Page Details", msg);
                        logValue.AddProperty("Warning Information", msg2);
                        logValue.AddProperty("Suggested Action", "Rename one or both of the pages to ensure a unique URL");
                        logValue.AddProperty("Hide this message", "To stop this message from appearing in the log, uncheck the option for 'Produce an Exception in the Site Log if two pages have the same name/path?' in the Advanced Url Rewriting settings.");
                        logValue.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString());
                        elc.AddLog(logValue);
                    }
                }
                else
                {
                    dupCheckDict.Remove(dupKey);
                    //add this tab to the duplicate key dictionary 
                    dupCheckDict.Add(dupKey, new DupKeyCheck(dupKey, tabId.ToString(), dupKey, isDeleted));
                }
            }
            else
            {
                //add this tab to the duplicate key dictionary - the dup key check dict is always maintained 
                //regardless of whether checking is employed or not
                dupCheckDict.Add(dupKey, new DupKeyCheck(dupKey, tabId.ToString(), dupKey, isDeleted));
            }
        }
コード例 #24
0
        public void PerformStepOne()
        {
            IDataReader dr;
            string      sqlStatement;
            var         objLogger = new DotNetNuke.Services.Log.EventLog.EventLogController();
            LogInfo     objLog;

            InsertLogNote("Starting Phase 1 Processing");

            //Remove temporary table if needed
            sqlStatement = "DROP TABLE dbo.[ICG_SMI_Passwords]";
            try
            {
                ExecuteNonQuery(sqlStatement);
            }
            catch (Exception)
            {
                //Table didn't exist
            }

            //Create temporary table
            sqlStatement = "CREATE TABLE dbo.[ICG_SMI_Passwords]( [UserId] [uniqueidentifier] NOT NULL, [Username] [nvarchar](256) NOT NULL, [OldPassword] [nvarchar](128) NOT NULL, [Password] [nvarchar](128) NULL, CONSTRAINT [PK_aspnet_Membership_Passwords] PRIMARY KEY CLUSTERED ( [UserId] ASC ) ON [PRIMARY] ) ON [PRIMARY]";
            try
            {
                ExecuteNonQuery(sqlStatement);
                objLog = new LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 1 Created Temp Password Table");
                objLog.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
            }
            catch (Exception ex)
            {
                objLog = new LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 1 Error Creating Temp Password Table " + ex);
                objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
            }

            InsertLogNote("Created temp password table");

            //Migrate over passwords
            sqlStatement = "INSERT INTO dbo.ICG_SMI_Passwords (UserId, Username, OldPassword, Password) SELECT dbo.aspnet_Users.UserId, Username, Password, NULL FROM dbo.aspnet_Users INNER JOIN dbo.aspnet_Membership ON dbo.aspnet_Users.UserId = dbo.aspnet_Membership.UserId";
            try
            {
                ExecuteNonQuery(sqlStatement);
                objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 1 Inserted User Accounts Into Temp Password Table");
                objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
            }
            catch (Exception ex)
            {
                objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 1 Error Inserting User Accounts Into Temp Password Table " + ex.ToString());
                objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
            }

            InsertLogNote("Migrated passwords to temporary table");

            //Decrypt passwords
            int processedUsers = 0;
            int decryptedUsers = 0;

            System.Web.Security.MembershipUser objUser;
            var wasSuccessful = false;

            sqlStatement = "SELECT * FROM dbo.ICG_SMI_Passwords";

            try
            {
                dr = ExecuteReader(sqlStatement);
                while (dr.Read())
                {
                    processedUsers++;
                    objUser = Membership.GetUser(dr.GetString(dr.GetOrdinal("Username")));
                    if (objUser != null)
                    {
                        try
                        {
                            var strPassword = objUser.GetPassword();
                            sqlStatement = "UPDATE dbo.ICG_SMI_Passwords SET Password = '******'", "''") + "' WHERE Username = '******'";
                            ExecuteNonQuery(sqlStatement);
                            decryptedUsers++;
                        }
                        catch (Exception)
                        {
                            //Unable to get this users password
                        }
                    }

                    //Provide status
                    if (processedUsers != 0 && (processedUsers % 1000) == 0)
                    {
                        objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                        objLog.AddProperty("SecureMyInstall", "Phase 1 User Accounts Processed: " + processedUsers.ToString());
                        objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                        objLogger.AddLog(objLog);
                    }
                }
                dr.Close();
                InsertLogNote(string.Format("Processed {0} user accounts", processedUsers.ToString()));
                InsertLogNote(string.Format("Decrypted {0} user password", decryptedUsers.ToString()));
                wasSuccessful = true;
            }
            catch (Exception)
            {
                //Oopsie
            }

            //Final eventLog entries
            objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
            objLog.AddProperty("SecureMyInstall", "Phase 1 User Accounts Processed: " + processedUsers.ToString());
            objLog.AddProperty("SecureMyInstall", "Phase 1 User Passwords Decrypted: " + decryptedUsers.ToString());
            objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
            objLogger.AddLog(objLog);

            if (wasSuccessful)
            {
                //Generate new keys
                var objSecurity      = new PortalSecurity();
                var newValidationKey = objSecurity.CreateKey(20);
                var newDecryptionKey = objSecurity.CreateKey(24);
                objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 1 New Machine Keys Generated");
                objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
                InsertLogNote("Phase 2 New Machine Keys Generated");

                //Update web.config, change keys as well as password format
                try
                {
                    DotNetNuke.Common.Utilities.Config.BackupConfig();
                    var xmlConfig = new XmlDocument();
                    xmlConfig = DotNetNuke.Common.Utilities.Config.Load();
                    var xmlMachineKey = xmlConfig.SelectSingleNode("configuration/system.web/machineKey");
                    XmlUtils.UpdateAttribute(xmlMachineKey, "validationKey", newValidationKey);
                    XmlUtils.UpdateAttribute(xmlMachineKey, "decryptionKey", newDecryptionKey);
                    var xmlMembershipProvider = xmlConfig.SelectSingleNode("configuration/system.web/membership/providers/add[@name='AspNetSqlMembershipProvider']");
                    XmlUtils.UpdateAttribute(xmlMembershipProvider, "passwordFormat", "Hashed");
                    XmlUtils.UpdateAttribute(xmlMembershipProvider, "enablePasswordRetrieval", "false");
                    DotNetNuke.Common.Utilities.Config.Save(xmlConfig);
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 1 Updated Web.Config With New Machine Keys and password format");
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }
                catch (Exception)
                {
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 1 Error Processing User Accounts");
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }
            }
        }
コード例 #25
0
        private void OnPageLoad(object sender, EventArgs e)
        {
            try
            {
                AnalyticsEngineCollection analyticsEngines = AnalyticsEngineConfiguration.GetConfig().AnalyticsEngines;
                if (analyticsEngines == null || analyticsEngines.Count == 0)
                {
                    return;
                }
                var page = (Page) sender;
                if ((page == null))
                {
                    return;
                }
                foreach (AnalyticsEngine engine in analyticsEngines)
                {
                    if ((!String.IsNullOrEmpty(engine.ElementId)))
                    {
                        AnalyticsEngineBase objEngine = null;
                        if ((!String.IsNullOrEmpty(engine.EngineType)))
                        {
                            Type engineType = Type.GetType(engine.EngineType);
                            if (engineType == null) 
                                objEngine = new GenericAnalyticsEngine();
                            else
                                objEngine = (AnalyticsEngineBase) Activator.CreateInstance(engineType);
                        }
                        else
                        {
                            objEngine = new GenericAnalyticsEngine();
                        }
                        if (objEngine != null)
                        {
                            string script = engine.ScriptTemplate;
                            if ((!String.IsNullOrEmpty(script)))
                            {
                                script = objEngine.RenderScript(script);
                                if ((!String.IsNullOrEmpty(script)))
                                {
                                    var element = (HtmlContainerControl) page.FindControl(engine.ElementId);
                                    if (element != null)
                                    {
                                        var scriptControl = new LiteralControl();
                                        scriptControl.Text = script;
                                        if (engine.InjectTop)
                                        {
                                            element.Controls.AddAt(0, scriptControl);
                                        }
                                        else
                                        {
                                            element.Controls.Add(scriptControl);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var objEventLog = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("Analytics.AnalyticsModule", "OnPageLoad");
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                Logger.Error(ex);

            }
        }
コード例 #26
0
        public static void UpdateServerActivity(ServerInfo server)
        {
            var existServer = GetServers().FirstOrDefault(s => s.ServerName == server.ServerName && s.IISAppName == server.IISAppName);
            var serverId = DataProvider.Instance().UpdateServerActivity(server.ServerName, server.IISAppName, server.CreatedDate, server.LastActivityDate, server.PingFailureCount, server.Enabled);
            
            server.ServerID = serverId;
            if (existServer == null
                || string.IsNullOrEmpty(existServer.Url)
                || (string.IsNullOrEmpty(existServer.UniqueId) && !string.IsNullOrEmpty(GetServerUniqueId())))
            {
                //try to detect the server url from url adapter.
                server.Url = existServer == null || string.IsNullOrEmpty(existServer.Url) ? GetServerUrl() : existServer.Url;
                //try to detect the server unique id from url adapter.
                server.UniqueId = existServer == null || string.IsNullOrEmpty(existServer.UniqueId) ? GetServerUniqueId() : existServer.UniqueId;

                UpdateServer(server);
            }

            
            //log the server info
            var log = new LogInfo();
            log.AddProperty(existServer != null ? "Server Updated" : "Add New Server", server.ServerName);
            log.AddProperty("IISAppName", server.IISAppName);
            log.AddProperty("Last Activity Date", server.LastActivityDate.ToString());
            log.LogTypeKey = existServer != null ? EventLogController.EventLogType.WEBSERVER_UPDATED.ToString() 
                                        : EventLogController.EventLogType.WEBSERVER_CREATED.ToString();
            LogController.Instance.AddLog(log);

            ClearCachedServers();
        }
コード例 #27
0
        private void LogResult(string message)
        {
            var portalSecurity = new PortalSecurity();

			var log = new LogInfo
            {
                LogPortalID = PortalSettings.PortalId,
                LogPortalName = PortalSettings.PortalName,
                LogUserID = UserId,
                LogUserName = portalSecurity.InputFilter(txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup)
            };
			
            if (string.IsNullOrEmpty(message))
            {
                log.LogTypeKey = "PASSWORD_SENT_SUCCESS";
            }
            else
            {
                log.LogTypeKey = "PASSWORD_SENT_FAILURE";
                log.LogProperties.Add(new LogDetailInfo("Cause", message));
            }
            
			log.AddProperty("IP", _ipAddress);
            
            LogController.Instance.AddLog(log);

        }
コード例 #28
0
ファイル: Initialize.cs プロジェクト: hungnt-me/Dnn.Platform
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// LogEnd logs the Application Start Event
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]    1/28/2005   Moved back to App_End from Logging Module
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void LogEnd()
        {
            try
            {
                ApplicationShutdownReason shutdownReason = HostingEnvironment.ShutdownReason;
                string shutdownDetail = "";
                switch (shutdownReason)
                {
                    case ApplicationShutdownReason.BinDirChangeOrDirectoryRename:
                        shutdownDetail = "The AppDomain shut down because of a change to the Bin folder or files contained in it.";
                        break;
                    case ApplicationShutdownReason.BrowsersDirChangeOrDirectoryRename:
                        shutdownDetail = "The AppDomain shut down because of a change to the App_Browsers folder or files contained in it.";
                        break;
                    case ApplicationShutdownReason.ChangeInGlobalAsax:
                        shutdownDetail = "The AppDomain shut down because of a change to Global.asax.";
                        break;
                    case ApplicationShutdownReason.ChangeInSecurityPolicyFile:
                        shutdownDetail = "The AppDomain shut down because of a change in the code access security policy file.";
                        break;
                    case ApplicationShutdownReason.CodeDirChangeOrDirectoryRename:
                        shutdownDetail = "The AppDomain shut down because of a change to the App_Code folder or files contained in it.";
                        break;
                    case ApplicationShutdownReason.ConfigurationChange:
                        shutdownDetail = "The AppDomain shut down because of a change to the application level configuration.";
                        break;
                    case ApplicationShutdownReason.HostingEnvironment:
                        shutdownDetail = "The AppDomain shut down because of the hosting environment.";
                        break;
                    case ApplicationShutdownReason.HttpRuntimeClose:
                        shutdownDetail = "The AppDomain shut down because of a call to Close.";
                        break;
                    case ApplicationShutdownReason.IdleTimeout:
                        shutdownDetail = "The AppDomain shut down because of the maximum allowed idle time limit.";
                        break;
                    case ApplicationShutdownReason.InitializationError:
                        shutdownDetail = "The AppDomain shut down because of an AppDomain initialization error.";
                        break;
                    case ApplicationShutdownReason.MaxRecompilationsReached:
                        shutdownDetail = "The AppDomain shut down because of the maximum number of dynamic recompiles of resources limit.";
                        break;
                    case ApplicationShutdownReason.PhysicalApplicationPathChanged:
                        shutdownDetail = "The AppDomain shut down because of a change to the physical path for the application.";
                        break;
                    case ApplicationShutdownReason.ResourcesDirChangeOrDirectoryRename:
                        shutdownDetail = "The AppDomain shut down because of a change to the App_GlobalResources folder or files contained in it.";
                        break;
                    case ApplicationShutdownReason.UnloadAppDomainCalled:
                        shutdownDetail = "The AppDomain shut down because of a call to UnloadAppDomain.";
                        break;
                    default:
                        shutdownDetail = "No shutdown reason provided.";
                        break;
                }
                var objEv = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.BypassBuffering = true;
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.APPLICATION_SHUTTING_DOWN.ToString();
                objEventLogInfo.AddProperty("Shutdown Details", shutdownDetail);
                objEv.AddLog(objEventLogInfo);

                Logger.InfoFormat("Application shutting down. Reason: {0}", shutdownDetail);
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            if (Globals.Status != Globals.UpgradeStatus.Install)
            {
                //purge log buffer
                LoggingProvider.Instance().PurgeLogBuffer();
            }
        }
コード例 #29
0
        public static AnalyticsEngineConfiguration GetConfig()
        {
            var config = new AnalyticsEngineConfiguration {AnalyticsEngines = new AnalyticsEngineCollection()};
            FileStream fileReader = null;
            string filePath = "";
            try
            {
                config = (AnalyticsEngineConfiguration) DataCache.GetCache("AnalyticsEngineConfig");
                if ((config == null))
                {
                    filePath = Common.Utilities.Config.GetPathToFile(Common.Utilities.Config.ConfigFileType.SiteAnalytics);

                    //Create a FileStream for the Config file
                    fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    var doc = new XPathDocument(fileReader);
                    config = new AnalyticsEngineConfiguration {AnalyticsEngines = new AnalyticsEngineCollection()};
                    foreach (XPathNavigator nav in
                        doc.CreateNavigator().Select("AnalyticsEngineConfig/Engines/AnalyticsEngine"))
                    {
                        var analyticsEngine = new AnalyticsEngine
                                                  {
                                                      EngineType = nav.SelectSingleNode("EngineType").Value,
                                                      ElementId = nav.SelectSingleNode("ElementId").Value,
                                                      InjectTop = Convert.ToBoolean(nav.SelectSingleNode("InjectTop").Value),
                                                      ScriptTemplate = nav.SelectSingleNode("ScriptTemplate").Value
                                                  };
                        config.AnalyticsEngines.Add(analyticsEngine);
                    }
                    if (File.Exists(filePath))
                    {
                        //Set back into Cache
                        DataCache.SetCache("AnalyticsEngineConfig", config, new DNNCacheDependency(filePath));
                    }
                }
            }
            catch (Exception ex)
            {
                //log it
                var objEventLog = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("Analytics.AnalyticsEngineConfiguration", "GetConfig Failed");
                objEventLogInfo.AddProperty("FilePath", filePath);
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                Logger.Error(objEventLogInfo);

            }
            finally
            {
                if (fileReader != null)
                {
                    //Close the Reader
                    fileReader.Close();
                }
            }
            return config;
        }
コード例 #30
0
        /// <summary>
        /// cmdResetPassword_Click runs when the password reset button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[JT]	04/13/2006  Created
        /// </history>
        protected void cmdResetPassword_Click(Object sender, EventArgs e)
        {
            string strMessage = Null.NullString;
            ModuleMessageType moduleMessageType = ModuleMessageType.GreenSuccess;
            bool canReset = true;
            string answer = String.Empty;

            if ((UseCaptcha && ctlCaptcha.IsValid) || (!UseCaptcha))
            {
                // No point in continuing if the user has not entered a username.
                if (!String.IsNullOrEmpty(txtUsername.Text.Trim()))
                {
                    PortalSecurity objSecurity = new PortalSecurity();

                    UserInfo objUser = UserController.GetUserByName(PortalSettings.PortalId, txtUsername.Text.Trim(), false);          
                    
                    if (objUser != null)
                    {
                        if (MembershipProviderConfig.RequiresQuestionAndAnswer)
                        {
                            // This is a simple check to see if this is our first or second pass through this event method.
                            if (User.UserID != objUser.UserID)
                            {
                                User = objUser;
                                canReset = false;

                                // Check to see if the user had enter an email and password question.
                                if (!String.IsNullOrEmpty(User.Membership.Email.Trim()) && !String.IsNullOrEmpty(User.Membership.PasswordQuestion.Trim()))
                                {
                                    tblQA.Visible = true;
                                    lblQuestion.Text = User.Membership.PasswordQuestion;
                                    txtAnswer.Text = String.Empty;                                    
                                    strMessage = Localization.GetString("RequiresQAndAEnabled", this.LocalResourceFile);
                                    moduleMessageType = ModuleMessageType.YellowWarning;
                                }
                                else
                                {
                                    strMessage = Localization.GetString("MissingEmailOrQuestion", this.LocalResourceFile);
                                    moduleMessageType = ModuleMessageType.RedError;
                                }                                
                            }
                            else
                            {
                                answer = txtAnswer.Text.Trim();
                                if (String.IsNullOrEmpty(answer))
                                {
                                    canReset = false;
                                    strMessage = Localization.GetString("EnterAnswer", this.LocalResourceFile);
                                    moduleMessageType = ModuleMessageType.RedError;
                                }
                            }
                        }                        
                    }
                    else
                    {   
                        canReset = false;
                        ResetControl();
                        strMessage = Localization.GetString("UsernameError", this.LocalResourceFile);
                        moduleMessageType = ModuleMessageType.YellowWarning;
                    }                   

                    if (canReset)
                    {
                        try
                        {
                            //UserController.ResetPassword(objUser, answer);
                            //Mail.SendMail(User, MessageType.PasswordReminder, PortalSettings);
                            strMessage = Localization.GetString("PasswordSent", this.LocalResourceFile);
                            moduleMessageType = ModuleMessageType.GreenSuccess;

                            EventLogController objEventLog = new EventLogController();
                            LogInfo objEventLogInfo = new LogInfo();
                            objEventLogInfo.AddProperty("IP", ipAddress);
                            objEventLogInfo.LogPortalID = PortalSettings.PortalId;
                            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                            objEventLogInfo.LogUserID = UserId;
                            objEventLogInfo.LogUserName = objSecurity.InputFilter(txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
                            objEventLogInfo.LogTypeKey = "PASSWORD_RESET_SUCCESS";
                            objEventLog.AddLog(objEventLogInfo);                            
                        }
                        catch (Exception)
                        {
                            strMessage = Localization.GetString("PasswordResetError", this.LocalResourceFile);
                            moduleMessageType = ModuleMessageType.RedError; 

                            EventLogController objEventLog = new EventLogController();
                            LogInfo objEventLogInfo = new LogInfo();
                            objEventLogInfo.AddProperty("IP", ipAddress);
                            objEventLogInfo.LogPortalID = PortalSettings.PortalId;
                            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                            objEventLogInfo.LogUserID = UserId;
                            objEventLogInfo.LogUserName = objSecurity.InputFilter(txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
                            objEventLogInfo.LogTypeKey = "PASSWORD_RESET_FAILURE";
                            objEventLog.AddLog(objEventLogInfo);                           
                        }  
                    }
                }
                else
                {
                    ResetControl();
                    strMessage = Localization.GetString("EnterUsername", this.LocalResourceFile);
                    moduleMessageType = ModuleMessageType.RedError;
                }

                UI.Skins.Skin.AddModuleMessage(this, strMessage, moduleMessageType);
            }
        }
コード例 #31
0
ファイル: Upgrade.cs プロジェクト: VegasoftTI/Dnn.Platform
        private static void FavIconsToPortalSettings()
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "FavIconsToPortalSettings");
            const string fileName = "favicon.ico";
            var portals = PortalController.Instance.GetPortals().Cast<PortalInfo>();

            foreach (var portalInfo in portals)
            {
                string localPath = Path.Combine(portalInfo.HomeDirectoryMapPath, fileName);

                if (File.Exists(localPath))
                {
                    try
                    {
                        int fileId;
                        var folder = FolderManager.Instance.GetFolder(portalInfo.PortalID, "");
                        if (!FileManager.Instance.FileExists(folder, fileName))
                        {
                            using (var stream = File.OpenRead(localPath))
                            {
                                FileManager.Instance.AddFile(folder, fileName, stream, /*overwrite*/ false);
                            }
                        }
                        fileId = FileManager.Instance.GetFile(folder, fileName).FileId;

                        new FavIcon(portalInfo.PortalID).Update(fileId);
                    }
                    catch (Exception e)
                    {
                        string message = string.Format("Unable to setup Favicon for Portal: {0}", portalInfo.PortalName);
                        var log = new LogInfo {LogTypeKey = EventLogController.EventLogType.ADMIN_ALERT.ToString()};
                        log.AddProperty("Issue", message);
                        log.AddProperty("ExceptionMessage", e.Message);
                        log.AddProperty("StackTrace", e.StackTrace);
                        LogController.Instance.AddLog(log);

                        Logger.Warn(message, e);
                    }
                }
            }
        }
コード例 #32
0
 private void UpgradeModule( EventMessage message )
 {
     string BusinessController = message.Attributes["BusinessControllerClass"].ToString();
     object oObject = Reflection.CreateObject( BusinessController, BusinessController );
     EventLogController objEventLog = new EventLogController();
     LogInfo objEventLogInfo;
     if( oObject is IUpgradeable )
     {
         // get the list of applicable versions
         string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].ToString().Split( ",".ToCharArray() );
         foreach( string Version in UpgradeVersions )
         {
             //call the IUpgradeable interface for the module/version
             string upgradeResults = ( (IUpgradeable)oObject ).UpgradeModule( Version );
             //log the upgrade results
             objEventLogInfo = new LogInfo();
             objEventLogInfo.AddProperty( "Module Upgraded", BusinessController );
             objEventLogInfo.AddProperty( "Version", Version );
             objEventLogInfo.AddProperty( "Results", upgradeResults );
             objEventLogInfo.LogTypeKey = EventLogController.EventLogType.MODULE_UPDATED.ToString();
             objEventLog.AddLog( objEventLogInfo );
         }
     }
     UpdateSupportedFeatures( oObject, Convert.ToInt32( message.Attributes["DesktopModuleId"] ) );
 }
コード例 #33
0
ファイル: Upgrade.cs プロジェクト: VegasoftTI/Dnn.Platform
        ///-----------------------------------------------------------------------------
        ///<summary>
        ///  UpgradeVersion upgrades a single version
        ///</summary>
        ///<remarks>
        ///</remarks>
        ///<param name = "scriptFile">The upgrade script file</param>
        ///<param name="writeFeedback">Write status to Response Stream?</param>
        ///<history>
        ///  [cnurse]	02/14/2007	created
        ///</history>
        ///-----------------------------------------------------------------------------
        public static string UpgradeVersion(string scriptFile, bool writeFeedback)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "UpgradeVersion:" + scriptFile);
            var version = new Version(GetFileNameWithoutExtension(scriptFile));
            string exceptions = Null.NullString;

            // verify script has not already been run
            if (!Globals.FindDatabaseVersion(version.Major, version.Minor, version.Build))
            {
                // execute script file (and version upgrades) for version
                exceptions = ExecuteScript(scriptFile, writeFeedback);

                // update the version
                Globals.UpdateDataBaseVersion(version);

                var log = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(),
                    BypassBuffering = true
                };
                log.AddProperty("Upgraded DotNetNuke", "Version: " + Globals.FormatVersion(version));
                if (exceptions.Length > 0)
                {
                    log.AddProperty("Warnings", exceptions);
                }
                else
                {
                    log.AddProperty("No Warnings", "");
                }
                LogController.Instance.AddLog(log);
            }
            if (string.IsNullOrEmpty(exceptions))
            {
                DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "UpgradeVersion:" + scriptFile);
            }
            else
            {
                DnnInstallLogger.InstallLogError(exceptions);
            }
            return exceptions;
        }
コード例 #34
0
        public void PerformStepTwo()
        {
            IDataReader dr;
            string      sqlStatement;
            var         objLogger = new EventLogController();
            LogInfo     objLog;

            InsertLogNote("Phase 2 Starting");

            //Set user passwords
            int            processedUsers = 0;
            int            resetUsers     = 0;
            MembershipUser objUser;
            var            wasSuccessful = false;

            sqlStatement = "SELECT * FROM dbo.ICG_SMI_Passwords WHERE Password IS NOT NULL";
            try
            {
                dr = ExecuteReader(sqlStatement);
                while (dr.Read())
                {
                    processedUsers++;
                    objUser = Membership.GetUser(dr.GetString(dr.GetOrdinal("Username")));
                    if (objUser != null)
                    {
                        try
                        {
                            //Reset password,
                            var tempPassword = objUser.ResetPassword();

                            //Now, set the password
                            objUser.ChangePassword(tempPassword, dr.GetString(dr.GetOrdinal("Password")));
                            resetUsers++;
                        }
                        catch (Exception)
                        {
                            //One user failed, they can request forgotten password
                        }
                    }

                    //Provide status
                    if (processedUsers != 0 && (processedUsers % 1000) == 0)
                    {
                        objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                        objLog.AddProperty("SecureMyInstall", "Phase 2 User Accounts Processed: " + processedUsers.ToString());
                        objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                        objLogger.AddLog(objLog);
                    }
                }

                dr.Close();
                InsertLogNote(string.Format("Processed {0} user accounts", processedUsers.ToString()));
                InsertLogNote(string.Format("Updated {0} user passwords", resetUsers.ToString()));
                wasSuccessful = true;
            }
            catch (Exception)
            {
                //Skippy dee-doo-da-day
            }

            objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
            objLog.AddProperty("SecureMyInstall", "Phase 2 User Accounts Processed: " + processedUsers.ToString());
            objLog.AddProperty("SecureMyInstall", "Phase 2 User Passwords Updated: " + resetUsers.ToString());
            objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
            objLogger.AddLog(objLog);

            if (wasSuccessful)
            {
                //Drop table
                sqlStatement = "DROP TABLE dbo.[ICG_SMI_Passwords]";
                try
                {
                    ExecuteNonQuery(sqlStatement);
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 2 Dropped Temp Password Table");
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }
                catch (Exception ex)
                {
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 2 Error Dropping Temp Password Table " + ex.ToString());
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }

                try
                {
                    var xmlConfig = new XmlDocument();
                    xmlConfig = DotNetNuke.Common.Utilities.Config.Load();
                    var xmlForms = xmlConfig.SelectSingleNode("configuration/system.web/authentication/forms");
                    XmlUtils.UpdateAttribute(xmlForms, "name", ".DOTNETNUKE" + DateTime.Now.ToString("yyyyMMddhhss"));
                    DotNetNuke.Common.Utilities.Config.Save(xmlConfig);
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 2 Updated Web.Config With New Forms Authentication Ticket Name");
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }
                catch (Exception ex)
                {
                    objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                    objLog.AddProperty("SecureMyInstall", "Phase 2 Error Updating Web.Config With New Forms Authentication Ticket Name " + ex.ToString());
                    objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objLogger.AddLog(objLog);
                }
            }
            else
            {
                objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
                objLog.AddProperty("SecureMyInstall", "Phase 2 Error Processing User Accounts");
                objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objLogger.AddLog(objLog);
            }
        }