grashoper has asked for the wisdom of the Perl Monks concerning the following question:
if ($Session->{'isAuthenticated'} && $Session->{'trackSession'} && ! +$Session->{'SessionTracked'}) { use OLE; my $Conn = CreateObject OLE "ADODB.Connection"; $Conn->Open("PROVIDER=SQLOLEDB;DATA SOURCE=$Session->{'sqlServer'} +;UID=$Session->{'sqlUser'};PWD=$Session->{'sqlPass'};DATABASE=$Sessio +n->{'dbName'}"); my $RS = $Server->CreateObject("ADODB.Recordset"); my $RS2 = $Server->CreateObject("ADODB.Recordset"); my $sql = "INSERT into t_Sessions (Site, SessionDate, SessionID, +System, Account, UserLevel, UserType, UserID, Name, UserClass, UserIP +, UserAgent, UserResolution, UserAcrobatVer, UserTimeSpent, Referrer) + values ('". substr($Request->ServerVariables("SERVER_NAME")->item( +),0,50). "','". MSSQLDate($Session->{'timeStart'}). "','". $Session->{'SessionID'}. "','". substr(uc($Session->{'usrSystem'}),0,3). "','". substr(uc($Session->{'usrAccount'}),0,3). "','". substr($Session->{'usrLevel'},0,5). "','". substr($Session->{'usrType'},0,3). "','". substr($Session->{'usrID'},0,15). "','". substr($Session->{'usrName'},0,50). "','". substr($Session->{'usrClass'},0,10). "','". substr($Request->ServerVariables("REMOTE_ADDR")->item( +),0,15). "','". substr($Request->ServerVariables("HTTP_USER_AGENT")->i +tem(),0,255). "','". substr($Session->{'screenX'}."x".$Session->{'screenY'} +,0,10). "','". $Session->{'acrobatVersion'}. "','0','". substr($Request->ServerVariables("HTTP_REFERER")->item +(),0,255). "');"; if ($Session->{'trackDB'}){lg("DB","$sql");} $RS = $Conn->Execute($sql); my $sqlQ = "SELECT idSession FROM t_Sessions WHERE SessionID='$Session->{'SessionID'}' AND SessionDate = '".MSSQLDate($Session->{'time +Start'})."';"; if ($Session->{'trackDB'}){lg("DB","$sqlQ");} $RS2->Open($sqlQ, $Conn); if (!$RS2->EOF()) { $Session->{'idSession'} = $RS2->Fields('idSession')->{Value}; $RS2->Close; $Session->{'SessionTracked'} = 1; } $Conn->Close; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: code snippet
by BrowserUk (Patriarch) on Jun 17, 2008 at 18:52 UTC | |
by grashoper (Monk) on Jun 17, 2008 at 19:03 UTC | |
by BrowserUk (Patriarch) on Jun 17, 2008 at 19:37 UTC | |
|
Re: code snippet
by Thelonius (Priest) on Jun 17, 2008 at 19:34 UTC | |
|
Re: code snippet
by ikegami (Patriarch) on Jun 18, 2008 at 00:00 UTC |