View Single Post
Old 07-06-2005, 03:59 AM   #8 (permalink)
SinisterMotives
Junkie
 
Here you go. It's pretty choice, if I say so myself.

Copy and paste the two code sections into separate files and name them as shown below. Launch the HTA application and use as before.

private_message_viewer.hta

Code:
<html>
 <head>
  <title>vBulletin Private Message Viewer</title>
  <hta:application id="htaTag" applicationname="vBulletin Private Message Viewer" border="thick" borderstyle="normal" caption="yes" icon="chrome/app.ico" showintaskbar="yes" singleinstance="yes" sysmenu="yes" contextmenu="no" version="1.0" windowstate="maximize" selection="no" scroll="no" innerborder="yes" maximizebutton="no" minimizebutton="yes" />
  <script type="text/javascript">
   function unescapeXML(txt) {
    var lt = "&lt;";
    while (txt.indexOf(lt) > -1) {
     txt = txt.replace(lt,'<');
    }
    var gt = "&gt;";
    while (txt.indexOf(gt) > -1) {
     txt = txt.replace(gt,'>');
    }
    var amp = "&amp;";
    while (txt.indexOf(amp) > -1) {
     txt = txt.replace(amp,'&');
    }
    return txt;
   }

   function PrivMsgViewer() {
    this.document = new ActiveXObject('Microsoft.XMLDOM');
    this.document.async = "false";
    this.document.load(document.forms['console'].xml_file.value);
    var msgs = this.document.getElementsByTagName('message');
    for (i=0;i<msgs.length;i++) {
     var txt = msgs.item(i).text;
     txt = txt.replace(/\[QUOTE=([ \w]*)\]/g,'<div style="padding: 5px; border: 1px dotted #aaaaaa; margin-bottom: 5px;"><b>Quote:</b><br /><i>Originally posted by $1</i><br /><br />');
     txt = txt.replace(/\[\/QUOTE\]/g,'</div>');
     txt = this.document.createCDATASection(txt);
     this.document.getElementsByTagName('message').item(i).replaceChild(txt,this.document.getElementsByTagName('message').item(i).firstChild);
    }
    this.stylesheet = new ActiveXObject('Microsoft.XMLDOM');
    this.stylesheet.async = "false";
    this.stylesheet.load('priv_msgs.xsl');
    this.html = this.document.transformNode(this.stylesheet);
    // var privMsgWin = window.open('','privMsgWin','width=600,height=800,scrollbars=yes');
    privMsgWin.document.open('text/html','replace');
    privMsgWin.document.write(unescapeXML(this.html));
    privMsgWin.document.close();
   }
   function process() {
    var viewer = new PrivMsgViewer();
   }
  </script>
 </head>
 <body><h1>vBulletin Private Message Viewer</h1>
  <form name="console">
   XML File: <input type="file" name="xml_file">
   <button onclick="process()">View Messages</button>
  </form>
  <center><iframe name="privMsgWin" width="780" height="600" src=""></iframe></center>
 </body>
</html>
priv_msgs.xsl

Code:
<?xml version="1.0" ?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html"/>
  <xsl:template match="privatemessages">
   <html>
    <head>
     <title>Private Messages</title>
     <style type="text/css">
      body {
       font-family : century gothic, news gothic, sans-serif;
       color: #ffffff;
       background : #002B33;
       padding : 20px 10px 20px 10px;
       margin : 0px;
      }
      .t {
       letter-spacing : 0.5em;
       font-weight : bold;
       color : #728E9C;
      }
      .ti {
       letter-spacing : 0.5em;
       font-weight : bold;
       font-size : 48px;
       color : #ffffff;
      }
      .a, .b {
       font-size : 13px;
      }
      .a {
       font-weight: bold;
       color : #FF6666;
      }
      .pm {
       padding: 5px 0px 5px 0px;
      }
      .message {
       font-size: 13px;
       padding: 5px;
       background: #1D444D;
      }
     </style>
    </head>
    <body>
     <center><span style="font-size: 40px;"><span class="ti">P</span><span class="t">rivate </span><span class="ti">M</span><span class="t">essages</span></span></center>
     <xsl:apply-templates/>
    </body>
   </html>
  </xsl:template>
  <xsl:template match="folder">
   <h1 class="t" style="font-size: 24px;"><xsl:value-of select="@name"/></h1>
   <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="privatemessage">
   <div class="pm"><xsl:apply-templates/></div>
  </xsl:template>
  <xsl:template match="datestamp">
   <span class="a">Sent: </span><span class="b"><xsl:apply-templates/><br/></span>
  </xsl:template>
  <xsl:template match="title">
   <span class="a">Subject: </span><span class="b"><xsl:apply-templates/><br/></span>
  </xsl:template>
  <xsl:template match="fromuser">
   <span class="a">From: </span><span class="b"><xsl:apply-templates/><br/></span>
  </xsl:template>
  <xsl:template match="touser">
   <span class="a">To: </span><span class="b"><xsl:apply-templates/><br/><br/></span>
  </xsl:template>
  <xsl:template match="message">
   <div class="message"><xsl:apply-templates/></div>
  </xsl:template>
 </xsl:stylesheet>
SinisterMotives is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40