AndyJarrett

Access Gmail through a proxy ?

This is just a very rough idea. So rough that i decided its best just to paste the code rather that even let you download it, unzip it just to see what it is. Basically if (for whatever reason) are stuck behind a proxy server that will not allow you to access your Gmail acocunt then have the following bit of code set up on your site. It uses the Gmail Atom Feeds, so only the subject line and date posted gets to be displayed - until Google change this.

To be honest i'm not behind a proxy so i can't test if this actually works so ANY feedback is welcome.To see the code click more

\n\n

\n

\n\n\n\n

<cfscript>
\n/**
\n * Convert a date in ISO 8601 format to an ODBC datetime.
\n *
\n * @param ISO8601dateString     The ISO8601 date string. (Required)
\n * @param targetZoneOffset     The timezone offset. (Required)
\n * @return Returns a datetime.
\n * @author David Satz (david_satz@hyperion.com)
\n * @version 1, September 28, 2004
\n */
\nfunction DateConvertISO8601(ISO8601dateString, targetZoneOffset) {
\n   var rawDatetime = left(ISO8601dateString,10) & " " & mid(ISO8601dateString,12,8);
\n   
\n   // adjust offset based on offset given in date string\n   if (uCase(mid(ISO8601dateString,20,1)) neq "Z")
\n      targetZoneOffset = targetZoneOffset - val(mid(ISO8601dateString,20,3)) ;
\n   
\n   return DateAdd("h", targetZoneOffset, CreateODBCDateTime(rawDatetime));

\n}
\n</cfscript>


\n<cfhttp url="https://gmail.google.com/gmail/feed/atom/" username="username" password="password here"></cfhttp>
\n<cfset gmailPosts = cfhttp.fileContent />

\n<cfset xmlPacket = xmlParse(gmailPosts) />
\n<cfset entries = xmlSearch(xmlPacket,"//:entry") />
\n<cfloop index="x" from="1" to="#arrayLen(entries)#">
\n <cfset node = structNew() />
\n <cfset node.title = entries[x].title.xmlText />
\n <cfset node.link = entries[x].link.xmlAttributes.href />
\n <cfif structKeyExists(entries[x],"content")>
\n     <cfset node.description = entries[x].content.xmlText />
\n <cfelse>
\n     <cfset node.description = "" />
\n </cfif>
\n <cfif structKeyExists(entries[x],"issued")>
\n <!--- Uses David Satz UDF from CFLIB.org --->
\n      <cfset node.date = dateConvertISO8601(entries[x].issued.xmlText,0) />
\n <cfelse>
\n <cfset node.date = "1/1/1" />
\n </cfif>
\n   
\n <cfoutput>
\n <table width="200" border="1">
\n <tr>
\n <th scope="row">Date</th>
\n <td>#dateFormat(node.date, 'dd-mmm-yyyy')# #timeFormat(node.date, 'HH:mm:ss')#</td>
\n </tr>
\n <tr>
\n <th scope="row">Title</th>
\n <td>#node.TITLE#</td>
\n </tr>
\n   <tr>
\n <th scope="row">Description</th>
\n <td>#node.DESCRIPTION#</td>
\n </tr>
\n <!--- The link is always is http://gmail.google.com/gmail - this might change ??
\n <tr>
\n <th scope="row">Link</th>
\n <td>#node.LINK#</td>
\n </tr>
\n   --->
\n </table>
\n   </cfoutput>
\n</cfloop>
Remember though that you details are passed in plain text. Also you might just want to put some validation on this page incase anyone comes across it.