home *** CD-ROM | disk | FTP | other *** search
- <%
- const ENCODING_PLAIN = 0
- const ENCODING_QUOTED = 1
- const ENCODING_BASE64 = 2
-
- function isDigit(char)
- {
- var i=number(char)
-
- if ((i>0)||(char=="0"))
- return true
- else
- return false
- }
-
- var wlStr=""
- function writeline(line, encoding, html, raw)
- {
- var wm = new server.webmail
- line = string(line)
- wlStr=wlStr+line.slice(0, line.length-1)
-
- if ((wlStr.length>=2)&&(encoding==ENCODING_QUOTED))
- {
- // is last character '='
- if ((wlStr.slice(wlStr.length-1, wlStr.length)!="=")&&(wlStr.slice(wlStr.length-2, wlStr.length)!="= "))
- {
- var index=wlStr.length-1
-
- var char=wlStr.slice(index, index+1)
- while ((index>=0)&&(isDigit(char))&&(char!="="))
- {
- index=index-1
- if (index>=0)
- char=wlStr.slice(index, index+1)
- }
-
- if (char=="=")
- wlStr=wlStr.slice(0, index)
-
- // if (html)
- // wlStr=wm.escape(wlStr)
-
- wlStr=wm.decode(1, wlStr)
-
- output.write(wlStr+"\r\n")
- wlStr=""
- }
- else
- {
- if (wlStr.slice(wlStr.length-1, wlStr.length)=="=")
- wlStr=wlStr.slice(0, wlStr.length-1)
- else
- wlStr=wlStr.slice(0, wlStr.length-2)
- }
- }
- else
- {
- if (encoding==ENCODING_BASE64)
- wlStr=wlStr.base64decode()
-
- wlStr=wm.decode(1, wlStr)
-
- // if (html)
- // wlStr=wm.escape(wlStr)
-
- if (encoding==ENCODING_BASE64)
- output.write(wlStr)
- else
- output.write(wlStr+"\r\n")
-
- wlStr=""
- }
- }
-
- function writeflush(encoding)
- {
- if (wlStr!="")
- {
- if (encoding==ENCODING_BASE64)
- output.write(wlStr)
- else
- output.write(wlStr+"\r\n")
- }
- }
-
- function writemimetext(msg, encoding)
- {
- msg.nexttext()
-
- var str=""
-
- var wm=new server.webmail
-
- var i
- for (i=0; i< msg.mime.linecount; i++)
- {
- var line=msg.text
-
- str=str+line.slice(0, line.length-1)
- if ((str.length>=2)&&(encoding==ENCODING_QUOTED))
- {
- // is last character '='
- if (str.slice(str.length-1, str.length)!="=")
- {
- var index=str.length-1
-
- var char=str.slice(index, index+1)
- while ((index>=0)&&(isDigit(char))&&(char!="="))
- {
- index=index-1
- if (index>=0)
- char=str.slice(index, index+1)
- }
-
- if (char=="=")
- str=str.slice(0, index)
-
- str=wm.escape(str)+"<BR>"
- str=wm.decode(1, str)
- output.write(str+"\r\n")
- str=""
- }
- else
- {
- str=str.slice(0, str.length-1)
- }
- }
- else
- {
- if (encoding==ENCODING_BASE64)
- str=str.base64decode()
-
- str=wm.escape(str)
-
- if (encoding==ENCODING_BASE64)
- {
- str=str.replace(str, "\r", "<BR>")
- output.write(str)
- }
- else
- output.writeln(str+"<BR>")
-
- str=""
- }
-
- msg.nexttext()
- }
- }
- %>