Antonio Grazioli Web Site
Web Technologies & more...

 

 

Main Menu
Home
News
Web Technologies
SQL Server
Portfolio
Downloads
Contact me
Syndication
Search...

Latest News

DDL Triggers in SQL Server 2005

SQL Server 2000 has Triggers. Triggers are a "special kind" of Stored Procedure which are automatically invoked when actions like INSERT, UPDATE or DELETE are performed on a database table. Therefore, triggers in SQL 2000 respond to DML (Data Manipulation Language) statements.

SQL Server 2005 introduced the concept of DDL (Data Definition Language) Triggers.
DDL operations are basiclly all CREATE, ALTER and DROP statements. This means that a DDL trigger is invoked when, as an example, a user creates or deletes a database object, or modifies it.

DDL triggers expose all the informations about he event that fired them by means of a function, which returns an XML fragment. This function is called eventdata().

 The eventdata() function outputs something like this:

<EVENT_INSTANCE>
    <EventType>CREATE_TABLE</EventType>
    <PostTime>2007-07-25T21:44:27.267</PostTime>
    <SPID>52</SPID>
    <ServerName>MyServer</ServerName>
    <LoginName>MyServer\User01</LoginName>
    <UserName>dbo</UserName>   
    <DatabaseName>HotelList</DatabaseName>
    <SchemaName>dbo</SchemaName>
    <ObjectName>Hotels</ObjectName>
    <ObjectType>TABLE</ObjectType>
        <TSQLCommand>   
            <SetOptions ANSI_NULLS="ON" ANSI_NULL_DEFAULT="ON"                                         ANSI_PADDING="ON" QUOTED_IDENTIFIER="ON" ENCRYPTED="FALSE"/>
            <CommandText>create table Hotels(name varchar(50),
            address varchar(30), stars int)</CommandText>
         </TSQLCommad>
</EVENT_INSTANCE>

 ...which basically contains all the info about the event that occurred.

A DDL trigger could then parse this XML data to extract info as needed, using the value method defined in SQL 2005 for XML variables.

This is an example of a DDL trigger (click to enlarge):

DDL Trigger Code

After creating a trigger similar to this one, just create a simple table and observe the effects.

 

 

 

 

 
Google Sitemap for phpBB Forums with ASP code

I needed to create a simple Google Sitemap for a phpBB Forum hosted on a Windows-based domain.
So I had to use ASP code...

I started form this script and made my modifications as usual. The final sitemap will contain all the topics in your phpB Forum.

PLEASE NOTE that my modification doesn't take into account private or protected forums, it just browses all available forums. Also, no URL rewriting or fancy stuff...

Use the following code and save it as an.asp page. Google accepted it with no problem. 

 

'change this for your connection file
<!--#include file="MyConnections.asp" -->
<%
MAXURLS_PER_SITEMAP = 50000

'modify this to change website, baseurl and table
baseurl="http://www.yoursite.com/Forum/viewtopic.php?t="

strsql = "SELECT * FROM phpbb_topics"

'see http://www.time.gov/ for utcOffset
utcOffset=1
response.ContentType = "text/xml"
response.write "<?xml version='1.0' encoding='UTF-8'?>"
response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>"

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_conn_MySql_STRING

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn

Do while not rs.eof
    if URLS<MAXURLS_PER_SITEMAP then

'modify this to change database field
        id_page=(rs("topic_id"))
        filelmdate=date()
        priority=1

if not isdate(filelmdate) then filelmdate=now()
        filedate=iso8601date(filelmdate,utcOffset)

if priority="" or priority>1.0 then priority="1.0"
response.write "<url><loc>"&(baseurl&id_page)&"</loc><lastmod>"&filedate&"</lastmod>
<priority>"&priority&"</priority></url>"
        URLS=URLS+1
        Response.Flush
    rs.movenext
end if
Loop
response.write "</urlset>"
rs.Close

Set rs = Nothing

conn.Close

Set conn = Nothing

Function iso8601date(dLocal,utcOffset)
    Dim d
    ' convert local time into UTC
    d = DateAdd("H",-1 * utcOffset,dLocal)

' compose the date
    iso8601date = Year(d) & "-" & Right("0" & Month(d),2) & "-" & Right("0" & Day(d),2) & "T" & _
        Right("0" & Hour(d),2) & ":" & Right("0" & Minute(d),2) & ":" & Right("0" & Second(d),2) & "Z"

End Function

%>
 
Revver Videos on a phpBB Forum

I have managed to put Revver Videos on a phpBB Forum

You have to install the Youtube Mod for phpBB first, which allows you to insert Youtube Videos. See official post on phpBB forums.
(please note that this Mod requires the "Multi BBCode Mod installed)

I have simply made some additional modification based on the Youtube Mod, using basically the same logic.

PLEASE NOTE That this is in no way an official Mod but just an implementation based on other code. Please always backup your files before making any modification!

Here are the additional lines of code you need to add:

1)  in your templates/[yourtemplate]/bbcode.tpl

#
#-----[ FIND ]------------------------------------------ 
#
<!-- END youtube -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN revver -->
<script src="http://flash.revver.com/player/1.0/player.js?mediaId:{REVVERID};
affiliateId:{AFFILIATEID};height:392;width:480;" type="text/javascript"></script>
<!-- END revver -->

 2) in your includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#
// [youtube]YouTube URL[/youtube] code..
$patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is";
$replacements[] = $bbcode_tpl['youtube'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
// [revver]Revver URL[/revver] code..
$patterns[] = "#\[revver\]http://(?:one\.)?revver.com/watch/([0-9A-Za-z-_]*)/flv/affiliate/([0-9A-Za-z-_]*)[^[]*\[/revver\]#is";
$replacements[] = $bbcode_tpl['revver'];

3) in your  includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl['youtube'] = str_replace('{YOUTUBEID}', '\\1', $bbcode_tpl['youtube']);
$bbcode_tpl['youtube'] = str_replace('{YOUTUBELINK}', $lang['youtube_link'], $bbcode_tpl['youtube']);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$bbcode_tpl['revver'] = str_replace('{REVVERID}', '\\1', $bbcode_tpl['revver']);
$bbcode_tpl['revver'] = str_replace('{AFFILIATEID}', '\\2', $bbcode_tpl['revver']);
 

This way, you can simply embed your Revver URL into [revver] and [/revver] tags.

If you like, you can also add a "Revver" button to automatically insert this tags, you should modify the existing array of buttons adding another one, making some more easy hacks to includes/bbcode.php and  templates/[yourtemplate]/posting_body.tpl

 

 

 
<< Start < Prev 1 2 3 Next > End >>

Results 9 - 12 of 12