<?
/*
Php Gmail Web Drive
version: 0.3.4
Copyright: Rahat Ayub (hide@address.com)
Mohd Faruq (hide@address.com)
Released under Lesser GNU Public licence(LGPL)
*****Please do not remove credit section below***
Credit:
1. Rahat Ayub for this small snippet;
2. LibGmailer for their excellent library (http://libgmailer.sourceforge.net);
3. Treemenu.net for Javascript menu;
4. Mohd Faruq for implementing the multi-folder support;
*****Change log***
(Faruq)
.noos DGP fo niosrev rewen a eb thgim ereht
!denut yatS
(Faruq)
3-June-2007
Fixed PHP5 bugs with classes.
(rahat)
Fixed Gmail security bug reported by Dmitri Ivanov.
(rahat)
Fixed Gmail access error. Updated LibGmailer.
(Faruq)
8-June-2005
Bug Fixing.
Known Bugs:
Files display is limited to 25/50/100..
7-June-2005
Change Tigra treeview to treemenu.net treeview.
Added support for multi-folders.
SourceCode cleaned. (Source rewritten in Zend Studio)
(Rahat Ayub)
24-may-2005
Gmail protocol update error. Fixed
29-Nov-2004
First release
*/
/* if caches is disabled
header("Content-type: text/html; charset=utf-8");
header("Pragma: no-cache"); // stop caching
*/
require_once("config.php");
require_once("libgmailer.php");
/*------------------------------------------------/
GmailFolder TreeMenu class
Description: This is a simple class for
displaying Javascript based File tree
Ack: Portion of files are copied from
http://www.treemenu.net/
-------------------------------------------------*/
class GmailFolder
{
var $TreeData;
var $ItemCount = 0;
var $Items;
var $aFolders;
var $FoldersN;
function AddItem($file_parent, $file_name, $file_link)
{
$this->TreeData .= " insDoc($file_parent, gLnk(\"S\", \"$file_name\", \"$file_link\"))\n";
}
function AddFolder($folder_var, $folder_parent, $folder_name)
{
$this->TreeData .= " $folder_var = insFld($folder_parent, gFld(\"$folder_name\", \"#\"))\n";
$this->aFolders[$this->FolderCounter] = $folder_name;
$this->FoldersN[$folder_name] = $folder_var;
//$this->TreeData .= "// Folder $folder_name created with the var $folder_var. ID $this->FolderCounter.\n";
$this->FolderCounter++;
}
function GmailFolder()
{
$this->TreeData .= "\nUSETEXTLINKS = 1\n";
$this->TreeData .= "STARTALLOPEN = 1\n";
$this->TreeData .= "USEFRAMES = 0\n";
$this->TreeData .= "USEICONS = 1\n";
$this->TreeData .= "WRAPTEXT = 1\n";
$this->TreeData .= "PRESERVESTATE = 1\n";
$this->TreeData .= "HIGHLIGHT = 1\n";
$this->TreeData .= "ICONPATH = \"./images/\"\n\n\n";
$this->TreeData .= "foldersTree = gFld(\"<b>Gmail Drive</b>\", \"#\")\n";
$this->TreeData .= "foldersTree.iconSrc = ICONPATH + \"base.gif\"\n";
$this->AddFolder("rootFolder", "foldersTree", "/");
}
function JSHeader()
{
echo "<script src=\"ua.js\"></script>\n";
echo "<script src=\"ftiens4.js\"></script>\n";
echo "<script language=\"JavaScript\">$this->TreeData</script>\n";
}
function Display()
{
echo "<span class=TreeviewSpanArea>\n";
echo "<script>initializeDocument()</script>\n";
echo "<noscript>\n";
echo "A tree for site navigation will open here if you enable JavaScript in your browser.\n";
echo "</noscript>\n";
echo "</span>\n";
}
}
$gf = new GmailFolder();
for ($a=0;$a<=$maxAccounts;$a++)
{
$gm[$a] = new GMailer();
$gm[$a]->setLoginInfo($gmail_user[$a], $gmail_password[$a], "+8"); // only required for connecting the first time,
if ($gm[$a]->connect()) { //
$gm[$a]->fetchBox(GM_STANDARD, "inbox", 0); // name of constants can be found in libgmailer.php
$snapshot = $gm[$a]->getSnapshot(GM_STANDARD);
$lastidx = count($snapshot->box)-1; //
//$gf->TreeData .= "// ".count($snapshot->box).".\n";
//$gf->TreeData .= "// ".$snapshot->box_total.".\n";
//for ($c=0;$c<=$snapshot->box_total;$c+1)
//{
//$gm[$a]->fetchBox(GM_STANDARD, "inbox", $c); // name of constants can be found in libgmailer.php
//$snapshot = $gm[$a]->getSnapshot(GM_STANDARD);
//$lastidx = count($snapshot->box)-1;
foreach ((array)$snapshot->box as $item) { //
$gm[$a]->fetchBox(GM_CONVERSATION, $item["id"], 0); // name of constants can be found in libgmailer.php
$snapshot1 = $gm[$a]->getSnapshot(GM_CONVERSATION);
foreach ((array)$snapshot1->conv as $item1) {
if (($att_filter == F_OFF) or
($att_filter == F_SELF and $item1["sender_email"] == $gmail_user[$a]) or
($att_filter == F_GMAILFS and preg_match("/^GMAILFS:/i", $item1["subj"]))){
for ($i = 0; $i < count($item1["attachment"]); $i++) {
$att_id = ""; //attachment ID
$att_file = ""; //attachment file name
$att_size = ""; //attachment size
$att_link = ""; //attachment link
$att_html = ""; //attachment html link code
$att_id = $item1["attachment"][$i]["id"];
$att_file .= urlencode($item1["attachment"][$i]["filename"]);
$att_link .="dl.php?a=".$att_id."&m=".$item1["id"]."&f=".$att_file."&n=".$a;
$att_html .= "<a href='".$att_link."'>"."</a> ";
$att_size .= $item1["attachment"][$i]["size"];
$gf->ItemCount++;
$gf->Items[$gf->ItemCount][0] = $att_id;
$gf->Items[$gf->ItemCount][1] = $att_file;
$gf->Items[$gf->ItemCount][2] = $att_link;
$gf->Items[$gf->ItemCount][3] = $att_html;
$gf->Items[$gf->ItemCount][4] = $att_size;
$gf->Items[$gf->ItemCount][5] = substr($item1["subj"], 10, strlen($item1["subj"]));
if (substr_count($gf->Items[$gf->ItemCount][5], "/") > 0)
{
$tempXP = explode("/", $gf->Items[$gf->ItemCount][5]);
if (!in_array($tempXP[0], $gf->aFolders))
{
// $gf->TreeData .= "// Folder $tempXP[0] doesn't exist.\n";
$gf->AddFolder("myMain_$gf->ItemCount", "rootFolder", $tempXP[0]);
$cFolder = "myMain_$gf->ItemCount";
}
else
{
// $gf->TreeData .= "// Folder $tempXP[0] exist.\n";
$cFolder = $gf->FoldersN[$tempXP[0]];
}
//$gf->TreeData .= "// Last folder is $cFolder .\n";
for ($i=1; $i<substr_count($gf->Items[$gf->ItemCount][5], "/"); $i++)
{
if (!in_array($tempXP[$i], $gf->aFolders))
{
// $gf->TreeData .= "// Folder $tempXP[$i] doesn't exist.\n";
$gf->AddFolder("Folder_$gf->ItemCount", $cFolder, $tempXP[$i]);
$cFolder = "Folder_$gf->ItemCount";
}
else
{
// $gf->TreeData .= "// Folder $tempXP[$i] exist.\n";
$cFolder = $gf->FoldersN[$tempXP[$i]];
}
}
//$gf->TreeData .= "// Last folder is $cFolder.\n";
if ($gf->Items[$gf->ItemCount][1] != ".")
$gf->AddItem($cFolder, $gf->Items[$gf->ItemCount][1], $gf->Items[$gf->ItemCount][2]);
}
else
{
$gf->AddItem("rootFolder", $gf->Items[$gf->ItemCount][1], $gf->Items[$gf->ItemCount][2]);
//$gf->TreeData .= "// Last folder is rootFolder.\n";
}
}
}
}
}
//}
$gm[$a]->disconnect();
}
}
$gf->TreeData .= "foldersTree.treeID = \"t2\"\n";
?>
<head>
<Title><?php echo $sitename ?></Title>
<style type="text/css">
<!--
.download {
font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style1 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; height: auto; width:auto }
.style4 {
color: #006600;
}
body {
background-color: #FFFFFF;
}
#content_wrapper {
position: relative;
width: 760px;
text-align: left;
height: auto;
padding: 0px;
margin: 12px 12px 12px 12px;
background-color: #FFFFFF;
top: -2px;
}
-->
</style>
<!-- SECTION 1 -->
<style>
/* styles for the tree */
SPAN.TreeviewSpanArea A {
font-size: 10pt;
font-family: verdana,helvetica;
text-decoration: none;
color: black
}
SPAN.TreeviewSpanArea A:hover {
color: '#820082';
}
/* rest of the document */
/* BODY {background-color: white} */
TD {
font-size: 10pt;
font-family: verdana,helvetica;
}
</style>
<?php
$gf->JSHeader();
?>
</head>
<body>
<img src="images/pgd_logo.gif" width="150" height="67" border="0">
<div id="content_wrapper">
<blockquote class="style1">
<p class="style4">
<table border=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" href=http://www.treemenu.net/ target=_blank>Javascript Tree Menu</a></font></td></table>
<?php
$gf->Display();
?>
</p>
</blockquote>
</div>
<hr>
<div id="content_wrapper">
<blockquote class="style1">
<p class="style4">
<p class="style1"> <strong>File Upload</strong><br>
- You can upload file with any GmailFS compliant utilities like <a href=http://www.viksoe.dk/code/gmail.htm>Drive Shell-extension</a> or <a href="http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html">mountableGmail FS </a><br>
- Gmail prevents direct upload of EXE files. <br>
<strong><br>
File Download</strong><br>
- Gmail attachments are often not stored in cache. If you fail to download file, just select the file and use "save as" option by right clicking of mouse. <br>
<strong> <br>
Install PGD in your site </strong><br>
-
<a href="http://pgd.sourceforge.net">PhpGmailDrive (PGD)</a> is free opensource utility. Download it from <a href="http://sourceforge.net/project/showfiles.php?group_id=125071&package_id=136821&release_id=336954">sourceforge site</a>. <br>
- Carefully follow PGD <a href="http://pgd.sourceforge.net/pgdtutorial/">installation guide</a>by <a href="http://pandablog.static.net.">Faruq</a><br>
- Demo of PGD is available at <a href="http://www.rahat-ayub.com/">Rahat Ayub</a>'s home page <br>
<br>
<strong>Disclaimer
</strong><br>
<FONT color=#ff0000>Using Gmail as File server is violation of GMAIL <A href="http://gmail.google.com/gmail/help/terms_of_use.html"
target=_blank>terms of service</A>.. so. you were warned</FONT>.<br>
<br>
</p>
</blockquote>
</div>
</body>