Back to "Невеличкий модуль стеження за . TEXT 0. 95 блогів..."

This is a viewer only at the moment see the article on how this works.

To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk

This is a preview from the server running through my markdig pipeline

Imported mostlylucidcouk

Невеличкий модуль стеження за . TEXT 0. 95 блогів...

Tuesday, 06 July 2004

Гаразд, дуже задокументовано, але це працює... це просто джерело для невеличкої версії HtpModule, яку слід вести до блогу. TEXT - досить простий, але який має надати змогу будь- кому, хто хоче це зробити на початку. Я докладаю докладну версію у певний момент (хоча просто хочу перевірити поведінку цієї шкірки за допомогою встановленого коду ; -)

використання системи;

за допомогою System. Web;

за допомогою System.Data;

за допомогою System. Data. SqlClient;

за допомогою Dottext.Framework;

використання System.Collections.Specialized;

за допомогою System.IO;

за допомогою System.Text;

за допомогою System. Xml.Serialation;

за допомогою System.Threading;

за допомогою System.Net;

за допомогою Microsoft.ApplicationBlocks.Data;

ExplaceControls

{

///

// Опис резюме для ViewTrackModule.

///

публічний клас ПереглядTrackModule: IHtpModule

{

region IHtpModule Члени

публічний контекст Init}HttpApplication)

{

context.EndRequest += нова подіяHandler}context_EndRequest);

}

публічна порожнеча

{

/// TODO: Додати реалізація ViewTrackModule. Dispose

}

endregion

///

// OK, трохи незвичний... але мені потрібен об' єкт BlogConfig для доступу до DB...

///

///

///

core void context_EndRequestobject відправник, ПодіяArgs e)

{

HttpApplication httpApp = відправник як HttpApplication;

System.Uri ur = httpApp.Request.UrlReferrer;

string testHost = string.Empty;

string thisHost = httpApp.Request.ServerVariables["SERVER_NAME"];

if}ur! = null)

{

testHost = ur.Host;

}

if}TestHost! = thisHost)

{

HtpRequest re = httpApp.Request;

LogToDBDel del = new LogToDBDel}LogToDB);

IAyncResult ar = del. BenginInvokere, null, null);

}

}

приватний делегат void LogToDBDel}HtpRequest re);

private void LogToDB}HtpRequest re)

{

string m_ connectionString = Dottext.Framework.Configuration.BlogConfigurationSettings. Instance}). BlogProviders.DbProvider. ConnectionString;

string clientIP = re.UserHostAddress;

if}!client. startsWith"192.) &&!client.StartsWith" 10 .")

{

string clientUserAgent = re.UserAgent;

string clientReferer = re. ServerVariables[HTTP_ REFERER"];

string clientHostName = string.Empty;

спробувати

{

clientHostName = Dns.GetHostByAddress}$clientIP). HostName;

}

fued}Особення)

{

clientHostName = re.UserHostName;

}

string clientQuery = re.RawUrl;

SqlParater[] sqlParrams = SqlHelperParameterCache.GetSpParameterSetm_ connectionString, "pr_Блог_SaveEntryStats";

sqlPrams[0]. Значення = clientIP;

sqlPrams[1]. Значення = clientUserAgent;

sqlPrams[2].Value = clientHostName;

sqlPrams[3].Value = clientQuery;

sqlPrams[4]. Value = Дата і час. Тепер;

sqlPrams[5].Value = clientReferer;

спробувати

{

SqlHelper.ExecuteNonquerym_ connectionString, CommandType.StoredProcedure, "pr_Блог_SaveEntryStats, sqlParams) ;

}

fued}Особення)

{

}

}

}

}

}

Зазвичай, для того, щоб з' єднатися з модулем, потрібен запис у мережі. config:

<httpModules> <add name=" RequestLogger" type=" ExtraControls.ViewTrackModule, ExtraControls" /> </ httpModules>

logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.