Changeset 12001

Show
Ignore:
Timestamp:
09/04/07 15:35:23 (1 year ago)
Author:
w_i
Message:

Some cleaning on the contactgrabber

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/com.magnettechnologies.contactgrabber/contactgrabber.php

    r11774 r12001  
    22 
    33/** 
    4  * This is some kind of a wrapper for the contactcrabber. 
    5  */ 
     4    * This is some kind of a wrapper for the contactcrabber. 
     5    */ 
    66 
    77/** 
    8   * Contact Grabber  
    9   * Version 0.3 
    10   * Released 9th May, 2007 
    11   * Author: Magnet Technologies, vishal.kothari@magnettechnologies.com 
    12   * Credits: Janak Prajapati, Pravin Shukla, Tapan Moharana 
    13   * Copyright (C) 2007 
    14  
    15   * This program is free software; you can redistribute it and/or 
    16   * modify it under the terms of the GNU General Public License 
    17   * as published by the Free Software Foundation; either version 2 
    18   * of the License, or (at your option) any later version. 
    19  
    20   * This program is distributed in the hope that it will be useful, 
    21   * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    22   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    23   * GNU General Public License for more details. 
    24  
    25   * You should have received a copy of the GNU General Public License 
    26   * along with this program; if not, write to the Free Software 
    27   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    28   **/ 
     8    * Contact Grabber  
     9    * Version 0.3 
     10    * Released 9th May, 2007 
     11    * Author: Magnet Technologies, vishal.kothari@magnettechnologies.com 
     12    * Credits: Janak Prajapati, Pravin Shukla, Tapan Moharana 
     13    * Copyright (C) 2007 
     14 
     15    * This program is free software; you can redistribute it and/or 
     16    * modify it under the terms of the GNU General Public License 
     17    * as published by the Free Software Foundation; either version 2 
     18    * of the License, or (at your option) any later version. 
     19 
     20    * This program is distributed in the hope that it will be useful, 
     21    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     22    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     23    * GNU General Public License for more details. 
     24 
     25    * You should have received a copy of the GNU General Public License 
     26    * along with this program; if not, write to the Free Software 
     27    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
     28    **/ 
    2929 
    3030 
     
    4040        $this->_component = 'com.magnettechnologies.contactgrabber'; 
    4141        parent::midcom_baseclasses_components_purecode(); 
    42          
     42 
    4343        $_MIDCOM->style->append_component_styledir('com.magnettechnologies.contactgrabber'); 
    44          
     44 
    4545        $_MIDCOM->add_link_head 
    4646        ( 
     
    4949                'rel' => 'stylesheet', 
    5050                'type' => 'text/css', 
    51                 'href' => MIDCOM_STATIC_URL."/com.magnettechnologies.contactgraper/styles/elements.css", 
     51                'href' => MIDCOM_STATIC_URL."/com.magnettechnologies.contactgrabber/styles/elements.css", 
    5252            ) 
    5353        ); 
    5454 
    5555        $_MIDCOM->enable_jquery(); 
    56         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/com.magnettechnologies.contactgraper/js/common.js'); 
     56        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/com.magnettechnologies.contactgrabber/js/common.js'); 
    5757    } 
    5858 
     
    6464            { 
    6565                require("lib/rediff/grabRediff.class.php"); 
    66                $this->_email = $_POST['username']; 
    67                $this->_resource_obj = new rediff();            
     66                $this->_email = $_POST['username']; 
     67                $this->_resource_obj = new rediff();           
    6868            } 
    6969 
     
    7171            { 
    7272                require("lib/gmail/libgmailer.php"); 
    73                $this->_email = $_POST['username']."@".$_POST['domain']; 
    74                $this->_resource_obj = new GMailer(); 
     73                $this->_email = $_POST['username']."@".$_POST['domain']; 
     74                $this->_resource_obj = new GMailer(); 
    7575            } 
    7676 
     
    7878            { 
    7979                require("lib/orkut/grabOrkut.class.php"); 
    80                $this->_email = $_POST['username']; 
     80                $this->_email = $_POST['username']; 
    8181                $this->_resource_obj = new orkut(); 
    8282            } 
     
    8585            { 
    8686                require("lib/myspace/grabMyspace.class.php"); 
    87                $this->_email = $_POST['username']; 
    88                $this->_resource_obj = new myspace(); 
    89             } 
    90  
    91            if($_POST['domain']=="yahoo.com") 
     87                $this->_email = $_POST['username']; 
     88                $this->_resource_obj = new myspace(); 
     89            } 
     90 
     91            if($_POST['domain']=="yahoo.com") 
    9292            { 
    9393                require("lib/yahoo/class.GrabYahoo.php"); 
    94                 $this->_email = $_POST['username']; 
    95                 $this->_resource_obj = new yahoo(); 
    96             } 
    97  
    98             if($_POST['domain']=="hotmail.com") 
    99             { 
    100                 //require("lib/hotmail/msn_contact_grab.class.php"); 
    101                 require('lib/hotmail/libhotmail.php'); 
    102                 $this->_email = $_POST['username']."@".$_POST['domain']; 
    103                 $this->_resource_obj = new hotmail(); 
    104             } 
    105  
    106             $this->_password =  $_POST['password']; 
    107         } 
    108     } 
    109  
    110     function _crab_contacts() 
     94                $this->_email = $_POST['username']; 
     95                $this->_resource_obj = new yahoo(); 
     96            } 
     97 
     98            // if($_POST['domain']=="hotmail.com") 
     99            // { 
     100            //     require("lib/hotmail/msn_contact_grab.class.php"); 
     101            //     $this->_email = $_POST['username']."@".$_POST['domain']; 
     102            //     $this->_resource_obj = new hotmail(); 
     103            // } 
     104 
     105            $this->_password =  $_POST['password']; 
     106        } 
     107    } 
     108 
     109    function _grab_contacts() 
    111110    { 
    112111        // $this->_show_search_form(); 
    113             $this->_create_resource_object(); 
    114  
    115         if (isset($this->_resource_obj)) 
    116             { 
    117             $contacts = $this->_resource_obj->getAddressbook($this->_email, $this->_password); 
    118             if(is_array($contacts)) 
    119             { 
    120                     $clean_contacts = array(); 
    121  
    122                     // Removing if email value is empty 
    123                 foreach($contacts['email'] as $key => $email) 
    124                 { 
    125                         if (!empty($email)) 
    126                     { 
    127                             $clean_contacts['email'][$key] = $email; 
    128                         $clean_contacts['name'][$key] = $contacts['name'][$key]; 
    129                     } 
    130                 } 
    131  
    132                     return $clean_contacts; 
    133             } 
    134         } 
     112        $this->_create_resource_object(); 
     113 
     114        if (isset($this->_resource_obj)) 
     115        { 
     116            $contacts = $this->_resource_obj->getAddressbook($this->_email, $this->_password); 
     117            if (   is_array($contacts) 
     118                && !empty($contacts)) 
     119            { 
     120                $clean_contacts = array(); 
     121 
     122                // Removing if email value is empty 
     123                foreach($contacts['email'] as $key => $email) 
     124                { 
     125                    if (!empty($email)) 
     126                    { 
     127                        $clean_contacts['email'][$key] = $email; 
     128                        $clean_contacts['name'][$key] = $contacts['name'][$key]; 
     129                    } 
     130                } 
     131 
     132                return $clean_contacts; 
     133            } 
     134        } 
    135135    } 
    136136 
     
    138138    { 
    139139        midcom_show_style('search-form'); 
     140         
     141        /* 
     142            <li class="ay" id="itab_item_yahoo"><a href="#invite_yahoo"></a></li> 
     143            --- 
     144            <li class="ay" id="itab_item_myspace"><a href="#invite_myspace"></a></li>             
     145            <li class="ay" id="itab_item_hotmail"><a href="#invite_hotmail"></a></li> 
     146            ---- 
     147             
     148            <div class="tabs_content" id="invite_yahoo"> 
     149                <h2>Invite your Yahoo friends</h2> 
     150                <div class="invite_login_form"> 
     151                    <form name="invite_yahoo" method="POST" onsubmit="return com_magnettechnologies_contactgrabber_validate(this);" action=""> 
     152                        <input type="hidden" name="domain" value="yahoo.com" /> 
     153                        <?php 
     154                        if ($email_parts[1] == 'yahoo.com') 
     155                        { 
     156                            $yahoo_user = $email_parts[0]; 
     157                        } 
     158                        ?> 
     159                        <label>Yahoo ID:</label><input class="text" type="text" name="username" value="&(yahoo_user);" /><label> @yahoo.com</label> 
     160                        <div class="clear_fix"></div> 
     161                        <label><?php echo $data['l10n']->get('password'); ?>:</label><input class="text" type="password" name="password" value="" /><input type="submit" name="sign_in" value="<?php echo $data['l10n']->get('fetch'); ?>" /> 
     162                    </form> 
     163                </div> 
     164                <div class="description"> 
     165                    <?php echo $_MIDCOM->i18n->get_string('no details are stored', 'com.magnettechnologies.contactgrabber'); ?> 
     166                </div> 
     167            </div> 
     168            --- 
     169            <div class="tabs_content" id="invite_myspace" style="display: none;"> 
     170                <h2>Invite your MySpace friends</h2> 
     171                <div class="invite_login_form"> 
     172                    <form name="invite_myspace" method="POST" onsubmit="return com_magnettechnologies_contactgrabber_validate(this);" action=""> 
     173                        <input type="hidden" name="domain" value="myspace.com" /> 
     174                        <label><?php echo $data['l10n']->get('username'); ?>:</label><input class="text" type="text" name="username" value="" /> 
     175                        <div class="clear_fix"></div> 
     176                        <label><?php echo $data['l10n']->get('password'); ?>:</label><input class="text" type="password" name="password" value="" /><input type="submit" name="sign_in" value="<?php echo $data['l10n']->get('fetch'); ?>" /> 
     177                    </form> 
     178                </div> 
     179                <div class="description"> 
     180                    <?php echo $_MIDCOM->i18n->get_string('no details are stored', 'com.magnettechnologies.contactgrabber'); ?> 
     181                </div> 
     182            </div>           
     183            <div class="tabs_content" id="invite_hotmail" style="display: none;"> 
     184                <h2>Invite your Hotmail friends</h2> 
     185                <div class="invite_login_form"> 
     186                    <form name="invite_hotmail" method="POST" onsubmit="return com_magnettechnologies_contactgrabber_validate(this);" action=""> 
     187                        <input type="hidden" name="domain" value="hotmail.com" /> 
     188                        <?php 
     189                        if ($email_parts[1] == 'hotmail.com') 
     190                        { 
     191                            $hotmail_user = $user_email; 
     192                        } 
     193                        ?> 
     194                        <label><?php echo $data['l10n']->get('username'); ?>:</label><input class="text" type="text" name="username" value="&(hotmail_user);" /> 
     195                        <div class="clear_fix"></div> 
     196                        <label><?php echo $data['l10n']->get('password'); ?>:</label><input class="text" type="password" name="password" value="" /><input type="submit" name="sign_in" value="<?php echo $data['l10n']->get('fetch'); ?>" /> 
     197                    </form> 
     198                </div> 
     199                <div class="description"> 
     200                    <?php echo $_MIDCOM->i18n->get_string('no details are stored', 'com.magnettechnologies.contactgrabber'); ?> 
     201                </div> 
     202            </div> 
     203        */ 
    140204    } 
    141205} 
  • trunk/midcom/com.magnettechnologies.contactgrabber/lib/gmail/libgmailer.php

    r11459 r12001  
    4141 * @var bool 
    4242 */ 
    43 define("GM_USE_LIB_AS_MODULE",         false); // Normal operation 
     43define("GM_USE_LIB_AS_MODULE",      false); // Normal operation 
    4444 
    4545/**#@+  
     
    4747 * @var string  
    4848 */ 
    49 define("GM_LNK_GMAIL",                 "https://mail.google.com/mail/"); 
    50 define("GM_LNK_GMAIL_HTTP",            "http://mail.google.com/mail/"); 
     49define("GM_LNK_GMAIL",              "https://mail.google.com/mail/"); 
     50define("GM_LNK_GMAIL_HTTP",        "http://mail.google.com/mail/"); 
    5151// Changed by Gan; 10 Sept 2005 
    52 define("GM_LNK_LOGIN",                         "https://www.google.com/accounts/ServiceLoginAuth"); 
     52define("GM_LNK_LOGIN",              "https://www.google.com/accounts/ServiceLoginAuth"); 
    5353// Added by Neerav; 4 Apr 2006 
    54 define("GM_LNK_LOGIN_REFER",           "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl&ltmpl=yj_blanco&ltmplcache=2&hl=en"); 
     54define("GM_LNK_LOGIN_REFER",        "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl&ltmpl=yj_blanco&ltmplcache=2&hl=en"); 
    5555// Added by Neerav; 5 June 2005 
    56 define("GM_LNK_INVITE_REFER",          "https://www.google.com/accounts/ServiceLoginBox?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail"); 
     56define("GM_LNK_INVITE_REFER",       "https://www.google.com/accounts/ServiceLoginBox?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail"); 
    5757// Updated by Neerav; 22 Aug 2006 
    5858define("GM_USER_AGENT", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6"); 
     
    6161 * @deprecated 
    6262 */ 
    63 define("GM_LNK_LOGOUT",                                "https://mail.google.com/mail/?logout"); 
    64 define("GM_LNK_REFER",                         "https://www.google.com/accounts/ServiceLoginBox?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail"); 
    65 define("GM_LNK_CONTACT",                       "https://mail.google.com/mail/?view=cl&search=contacts&pnl=a"); 
    66 define("GM_LNK_ATTACHMENT",                    "https://mail.google.com/mail/?view=att&disp=att"); 
    67 define("GM_LNK_ATTACHMENT_ZIPPED",     "https://mail.google.com/mail/?view=att&disp=zip"); 
     63define("GM_LNK_LOGOUT",             "https://mail.google.com/mail/?logout"); 
     64define("GM_LNK_REFER",              "https://www.google.com/accounts/ServiceLoginBox?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail"); 
     65define("GM_LNK_CONTACT",            "https://mail.google.com/mail/?view=cl&search=contacts&pnl=a"); 
     66define("GM_LNK_ATTACHMENT",         "https://mail.google.com/mail/?view=att&disp=att"); 
     67define("GM_LNK_ATTACHMENT_ZIPPED",  "https://mail.google.com/mail/?view=att&disp=zip"); 
    6868/**#@-*/ 
    6969 
     
    7272 * @var int  
    7373*/ 
    74 define("GM_STANDARD",                  0x001); 
    75 define("GM_LABEL",                             0x002); 
    76 define("GM_CONVERSATION",              0x004); 
    77 define("GM_QUERY",                             0x008); 
    78 define("GM_CONTACT",                   0x010); 
    79 define("GM_PREFERENCE",                        0x020); 
     74define("GM_STANDARD",           0x001); 
     75define("GM_LABEL",              0x002); 
     76define("GM_CONVERSATION",       0x004); 
     77define("GM_QUERY",              0x008); 
     78define("GM_CONTACT",            0x010); 
     79define("GM_PREFERENCE",         0x020); 
    8080/**#@-*/ 
    8181 
     
    8787 * Apply label to conversation 
    8888*/ 
    89 define("GM_ACT_APPLYLABEL",            1); 
     89define("GM_ACT_APPLYLABEL",     1); 
    9090/** 
    9191 * Remove label from conversation 
    9292*/ 
    93 define("GM_ACT_REMOVELABEL",   2); 
     93define("GM_ACT_REMOVELABEL",    2); 
    9494/** 
    9595 * Star a conversation 
    9696*/ 
    97 define("GM_ACT_STAR",                  3); 
     97define("GM_ACT_STAR",           3); 
    9898/** 
    9999 * Remove a star from (unstar) a conversation 
    100100*/ 
    101 define("GM_ACT_UNSTAR",                        4); 
     101define("GM_ACT_UNSTAR",         4); 
    102102/** 
    103103 * Mark a conversation as spam 
    104104*/ 
    105 define("GM_ACT_SPAM",                  5); 
     105define("GM_ACT_SPAM",           5); 
    106106/** 
    107107 * Unmark a conversation from spam 
    108108*/ 
    109 define("GM_ACT_UNSPAM",                        6); 
     109define("GM_ACT_UNSPAM",         6); 
    110110/** 
    111111 * Mark conversation as read 
    112112*/ 
    113 define("GM_ACT_READ",                  7); 
     113define("GM_ACT_READ",           7); 
    114114/** 
    115115 * Mark conversation as unread 
    116116*/ 
    117 define("GM_ACT_UNREAD",                        8); 
     117define("GM_ACT_UNREAD",         8); 
    118118/** 
    119119 * Trash a conversation 
    120120*/ 
    121 define("GM_ACT_TRASH",                 9); 
     121define("GM_ACT_TRASH",          9); 
    122122/** 
    123123 * Directly delete a conversation 
    124124*/ 
    125 define("GM_ACT_DELFOREVER",            10); 
     125define("GM_ACT_DELFOREVER",     10); 
    126126/** 
    127127 * Archive a conversation 
    128128*/ 
    129 define("GM_ACT_ARCHIVE",               11); 
     129define("GM_ACT_ARCHIVE",        11); 
    130130/** 
    131131 * Move conversation to Inbox 
    132132*/ 
    133 define("GM_ACT_INBOX",                 12); 
     133define("GM_ACT_INBOX",          12); 
    134134/** 
    135135 * Move conversation out of Trash 
    136136*/ 
    137 define("GM_ACT_UNTRASH",               13); 
     137define("GM_ACT_UNTRASH",        13); 
    138138/** 
    139139 * Discard a draft 
    140140*/ 
    141 define("GM_ACT_UNDRAFT",               14); 
     141define("GM_ACT_UNDRAFT",        14); 
    142142/** 
    143143 * Trash individual message. 
    144144*/  
    145 define("GM_ACT_TRASHMSG",              15);             
     145define("GM_ACT_TRASHMSG",       15);         
    146146/** 
    147147 * Untrash (retrieve from trash) individual message. 
    148148 * @since 27 Feb 2006 
    149149*/  
    150 define("GM_ACT_UNTRASHMSG",            18);             
     150define("GM_ACT_UNTRASHMSG",     18);         
    151151/** 
    152152 * Delete spam, forever. 
    153153*/  
    154 define("GM_ACT_DELSPAM",               16); 
     154define("GM_ACT_DELSPAM",        16); 
    155155/** 
    156156 * Delete trash message, forever. 
    157157*/  
    158 define("GM_ACT_DELTRASHED",            17); 
     158define("GM_ACT_DELTRASHED",     17); 
    159159/** 
    160160 * Deleted trashed messages from the thread forever. 
    161161 * @since 27 Feb 2006 
    162162*/  
    163 define("GM_ACT_DELTRASHEDMSGS",        19); 
     163define("GM_ACT_DELTRASHEDMSGS", 19); 
    164164/**#@-*/ 
    165165 
     
    168168*/ 
    169169define("GM_VER", "0.9 Beta 4"); 
    170 define("GM_COOKIE_KEY",                        "LIBGMAILER"); 
    171 define("GM_COOKIE_IK_KEY",             "LIBGMAILER_IdKey");    // Added by Neerav; 6 July 2005 
    172 define("GM_USE_COOKIE",                        0x001); 
    173 define("GM_USE_PHPSESSION",    0x002); 
     170define("GM_COOKIE_KEY",         "LIBGMAILER"); 
     171define("GM_COOKIE_IK_KEY",      "LIBGMAILER_IdKey");    // Added by Neerav; 6 July 2005 
     172define("GM_USE_COOKIE",         0x001); 
     173define("GM_USE_PHPSESSION",     0x002); 
    174174if (!defined("GM_COOKIE_TTL"))  {  
    175        $ttl = 60*60*24*7; 
    176        define("GM_COOKIE_TTL",         $ttl);  
     175    $ttl = 60*60*24*7; 
     176    define("GM_COOKIE_TTL",     $ttl);  
    177177} 
    178178/**#@-*/ 
     
    202202    * @var string 
    203203   */ 
    204        var $cookie_str; 
    205        var $login; 
    206        var $pwd; 
    207        /** 
    208         * Email domain 
    209        
    210         * Support for "Gmail for your domain".  
    211         * Domain name of email address to check.   
    212        
    213         * @access private 
    214         * @var string 
    215         * @author Neerav 
    216         * @since 8 Jun 2006 
    217        */ 
    218        var $domain; 
    219        var $GM_LNK_GMAIL                       = GM_LNK_GMAIL; 
    220        var $GM_LNK_GMAIL_HTTP          = GM_LNK_GMAIL_HTTP; 
    221        var $GM_LNK_LOGIN                       = GM_LNK_LOGIN; 
    222        var $GM_LNK_LOGIN_REFER         = GM_LNK_LOGIN_REFER; 
    223        var $GM_LNK_INVITE_REFER        = GM_LNK_INVITE_REFER; 
    224          
    225        /** 
    226         * @author Neerav 
    227         * @since 13 Aug 2005 
    228        */ 
    229        var $gmail_data; 
    230        /** 
    231         * Raw packet 
    232        */ 
    233        var $raw; 
    234        /** 
    235         * Raw packet for contact list 
    236        */ 
    237        var $contact_raw; 
    238        var $timezone; 
    239        var $use_session; 
    240        var $proxy_host; 
    241         var $proxy_auth;         
    242        /**#@-*/         
    243          
    244        /** 
    245         * Reserved mailbox names 
    246        */ 
    247        var $gmail_reserved_names = array("inbox", "star", "starred", "chat", "chats", "draft", "drafts",  
    248                        "sent", "sentmail", "sent-mail", "sent mail", "all", "allmail", "all-mail", "all mail", 
    249                        "anywhere", "archive", "spam", "trash", "read", "unread"); 
    250          
    251        /** 
    252         * @access public 
    253         * @var bool 
    254        */ 
     204    var $cookie_str; 
     205    var $login; 
     206    var $pwd; 
     207    /** 
     208    * Email domain 
     209   
     210    * Support for "Gmail for your domain".  
     211    * Domain name of email address to check.   
     212   
     213    * @access private 
     214    * @var string 
     215    * @author Neerav 
     216    * @since 8 Jun 2006 
     217    */ 
     218    var $domain; 
     219    var $GM_LNK_GMAIL           = GM_LNK_GMAIL; 
     220    var $GM_LNK_GMAIL_HTTP      = GM_LNK_GMAIL_HTTP; 
     221    var $GM_LNK_LOGIN           = GM_LNK_LOGIN; 
     222    var $GM_LNK_LOGIN_REFER     = GM_LNK_LOGIN_REFER; 
     223    var $GM_LNK_INVITE_REFER    = GM_LNK_INVITE_REFER; 
     224     
     225    /** 
     226    * @author Neerav 
     227    * @since 13 Aug 2005 
     228    */ 
     229    var $gmail_data; 
     230    /** 
     231    * Raw packet 
     232    */ 
     233    var $raw; 
     234    /** 
     235    * Raw packet for contact list 
     236    */ 
     237    var $contact_raw; 
     238    var $timezone; 
     239    var $use_session; 
     240    var $proxy_host; 
     241    var $proxy_auth;     
     242    /**#@-*/     
     243     
     244    /** 
     245    * Reserved mailbox names 
     246    */ 
     247    var $gmail_reserved_names = array("inbox", "star", "starred", "chat", "chats", "draft", "drafts",  
     248            "sent", "sentmail", "sent-mail", "sent mail", "all", "allmail", "all-mail", "all mail", 
     249            "anywhere", "archive", "spam", "trash", "read", "unread"); 
     250     
     251    /** 
     252    * @access public 
     253    * @var bool 
     254    */ 
    255255   var $created; 
    256256   /** 
    257         * Status of GMailer 
    258        
    259         * If something is wrong, check this class property to see what is 
    260         * going wrong. 
    261        
    262         * @author Neerav 
    263         * @since 8 July 2005 
    264         * @var mixed[] 
    265         * @access public 
    266        */ 
    267        var $return_status = array(); 
    268  
    269          
    270        /** 
    271         * Constructor of GMailer 
    272        
    273         * During the creation of GMailer object, it will perform several tests to see 
    274         * if the cURL extension is available or not. However,  
    275         * note that the constructor will NOT return false or null even if these tests 
    276         * are failed. You will have to check the class property {@link GMailer::$created} to see if 
    277         * the object "created" is really, uh, created (i.e. working), and property 
    278         * {@link GMailer::$return_status} or method {@link GMailer::lastActionStatus()} to see what was going wrong. 
    279        
    280         * Example: 
    281         * <code> 
    282         * <?php 
    283         *    $gmailer = new GMailer(); 
    284         *    if (!$gmailer->created) { 
    285         *       echo "Error message: ".$gmailer->lastActionStatus("message"); 
    286         *    } else { 
    287         *       // Do something with $gmailer 
    288         *    } 
    289         * ? > 
    290         * </code> 
    291        
     257    * Status of GMailer 
     258   
     259    * If something is wrong, check this class property to see what is 
     260    * going wrong. 
     261   
     262    * @author Neerav 
     263    * @since 8 July 2005 
     264    * @var mixed[] 
     265    * @access public 
     266    */ 
     267    var $return_status = array(); 
     268 
     269     
     270    /** 
     271    * Constructor of GMailer 
     272   
     273    * During the creation of GMailer object, it will perform several tests to see 
     274    * if the cURL extension is available or not. However,  
     275    * note that the constructor will NOT return false or null even if these tests 
     276    * are failed. You will have to check the class property {@link GMailer::$created} to see if 
     277    * the object "created" is really, uh, created (i.e. working), and property 
     278    * {@link GMailer::$return_status} or method {@link GMailer::lastActionStatus()} to see what was going wrong. 
     279   
     280    * Example: 
     281    * <code> 
     282    * <?php 
     283    *    $gmailer = new GMailer(); 
     284    *    if (!$gmailer->created) { 
     285    *       echo "Error message: ".$gmailer->lastActionStatus("message"); 
     286    *    } else { 
     287    *       // Do something with $gmailer 
     288    *    } 
     289    * ? > 
     290    * </code> 
     291   
    292292    * A typical usage of GMailer object would be like this: 
    293293    * <code> 
     
    309309    *    } 
    310310    * ? > 
    311     * </code>   
    312        
    313         * @see GMailer::$created, GMailer::$return_status, GMailer::lastActionStatus() 
    314         * @return GMailer 
    315        */ 
    316        function GMailer() { 
    317                // GMailer needs "curl" extension to work 
    318                $this->created = true; 
    319                if (!extension_loaded('curl')) { 
    320                        // Added to gracefully handle multithreaded servers; by Neerav; 8 July 2005 
    321                        if (isset($_ENV["NUMBER_OF_PROCESSORS"]) and ($_ENV["NUMBER_OF_PROCESSORS"] > 1)) { 
    322                                $this->created = false; 
    323                                $a = array( 
    324                                        "action"                => "constructing GMailer object", 
    325                                        "status"                => "failed", 
    326                                        "message"               => "libgmailer: Using a multithread server. Ensure php_curl.dll has been enabled (uncommented) in your php.ini." 
    327                                ); 
    328                                array_unshift($this->return_status, $a); 
    329  
    330                        } else { 
    331                                if (/*!dl('php_curl.dll') &&*/ !dl('curl.so')) { 
    332                                        $this->created = false; 
    333                                        $a = array( 
    334                                                "action"                => "constructing GMailer object", 
    335                                                "status"                => "failed", 
    336                                                "message"               => "libgmailer: unable to load curl extension." 
    337                                        ); 
    338                                        array_unshift($this->return_status, $a); 
    339                                
    340                        
    341                
    342                if (!function_exists("curl_setopt")) {                     
    343                        $this->created = false; 
    344                        $a = array( 
    345                                "action"                => "constructing GMailer object", 
    346                                "status"                => "failed", 
    347                                "message"               => "libgmailer: No curl." 
    348                        ); 
    349                        array_unshift($this->return_status, $a); 
    350                
    351  
    352                $this->login            = 0; 
    353                $this->pwd                      = 0; 
    354                $this->domain           = "";   // blank for @gmail.com and @googlemail.com 
    355                $this->proxy_host       = ""; 
    356                $this->proxy_auth       = ""; 
    357                $this->use_session      = 2; 
    358  
    359                if ($this->created == true) { 
    360                        $a = array( 
    361                                "action"                => "constructing GMailer object", 
    362                                "status"                => "success", 
    363                                "message"               => "libgmailer: Constructing completed." 
    364                        ); 
    365                        array_unshift($this->return_status, $a); 
    366                
    367        
    368          
    369        /** 
    370        * Set Gmail's login information. 
    371        
    372        * @return void 
    373        * @param string $my_login Gmail's login name (without @gmail.com) 
    374        * @param string $my_pwd Password 
    375        * @param float $my_tz Timezone with respect to GMT, but in decimal. For example, -2.5 for -02:30GMT 
    376        */ 
    377        function setLoginInfo($my_login, $my_pwd, $my_tz) { 
    378                $this->login    = $my_login; 
    379                $this->pwd              = $my_pwd; 
    380                $this->timezone = strval($my_tz*-60); 
    381  
    382                // Added return_status; by Neerav; 16 July 2005 
    383                $a = array( 
    384                        "action"                => "set login info", 
    385                        "status"                => "success", 
    386                        "message"               => "libgmailer: LoginInfo set." 
    387                ); 
    388                array_unshift($this->return_status, $a); 
    389        
    390          
    391        /** 
    392        * Set domain information if the account is on a hosted domain. 
    393        
    394        * @return void 
    395        * @param string $my_domain Hosted domain name (e.g., mydomain.org or sayni.net) 
    396        */ 
    397        function setDomain($my_domain) { 
    398                //return; 
    399                $my_domain = strtolower(trim($my_domain)); 
    400                if ($my_domain === "") { 
    401                        $a = array( 
    402                                "action"                => "set hosted domain info", 
    403                                "status"                => "sucess", 
    404                                "message"               => "libgmailer: Using the default gmail/googlemail domain." 
    405                        ); 
    406                        array_unshift($this->return_status, $a); 
    407                        return; 
    408                
    409                $success = true; 
    410                if (preg_match("/gmail\.com|googlemail\.com/i",$my_domain)) { 
    411                        $a = array( 
    412                                "action"                => "set hosted domain info", 
    413                                "status"                => "failed", 
    414                                "message"               => "libgmailer: cannot use \"$my_domain\" as a hosted domain.  The default gmail.com or googlemail.com will be used." 
    415                        ); 
    416                        array_unshift($this->return_status, $a); 
    417                        return; 
    418                
    419                $this->domain = $my_domain; 
    420 /*             $this->GM_LNK_GMAIL             = "https://mail.google.com/hosted/".$my_domain; */ 
    421 /*             $this->GM_LNK_GMAIL_HTTP        = "http://mail.google.com/hosted/".$my_domain; */ 
    422 /*             $this->GM_LNK_LOGIN             = "https://www.google.com/hosted/".$my_domain."/LoginAction"; */ 
    423 /*             $this->GM_LNK_LOGIN_REFER       = "https://www.google.com/hosted/".$my_domain."/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fhosted%2F".$my_domain."&ltmpl=yj_blanco&ltmplcache=2"; */ 
    424                // GFYD urls changed to GAFYD; Neerav; 1 Sept 2006 
    425                $this->GM_LNK_GMAIL             = "https://mail.google.com/hosted/".$my_domain; 
    426                $this->GM_LNK_GMAIL_HTTP        = "http://mail.google.com/hosted/".$my_domain; 
    427                $this->GM_LNK_LOGIN             = "https://www.google.com/a/".$my_domain."/LoginAction"; 
    428                $this->GM_LNK_LOGIN_REFER       = "https://www.google.com/a/".$my_domain."/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fhosted%2F".$my_domain."&ltmpl=yj_blanco&ltmplcache=2"; 
    429                $this->GM_LNK_INVITE_REFER      = ""; 
    430  
    431                $a = array( 
    432                        "action"                => "set hosted domain info", 
    433                        "status"                => "success", 
    434                        "message"               => "libgmailer: Domain set." 
    435                ); 
    436                array_unshift($this->return_status, $a); 
    437        
    438  
    439        /** 
    440        * Setting proxy server. 
    441        
    442        * Example: 
    443        * <code> 
    444        * <?php 
    445        *    // proxy server requiring login 
    446        *    $gmailer->setProxy("proxy.company.com", "my_name", "my_pwd"); 
    447        *  
    448        *    // proxy server without login 
    449        *    $gmailer->setProxy("proxy2.company.com", "", ""); 
    450        * ? > 
    451        * </code> 
    452         *        
    453        * @return void 
    454        * @param string $host Proxy server's hostname 
    455        * @param string $username User name if login is required 
    456        * @param string $pwd Password if required 
    457        */ 
    458        function setProxy($host, $username, $pwd) { 
    459                if (strlen($this->proxy_host) > 0) { 
    460                        $this->proxy_host = $host; 
    461                        if (strlen($username) > 0 || strlen($pwd) > 0) { 
    462                                $this->proxy_auth = $username.":".$pwd; 
    463                        
    464                        $a = array( 
    465                                "action"                => "set proxy", 
    466                                "status"                => "success", 
    467                                "message"               => "libgmailer: Proxy set." 
    468                        ); 
    469                        array_unshift($this->return_status, $a); 
    470                } else { 
    471                        $a = array( 
    472                                "action"                => "set proxy", 
    473                                "status"                => "failed", 
    474                                "message"               => "libgmailer: no hostname supplied." 
    475                        ); 
    476                        array_unshift($this->return_status, $a); 
    477                
    478        
    479          
    480        /** 
    481        * Setting session management method. 
    482        *  
    483        * You have to select a session management method so that GMailer would "remember" 
    484        * your identity. Method has to be one of the following values: 
    485        * 1. {@link GM_USE_COOKIE} | !{@link GM_USE_PHPSESSION} (if your server does not have PHP Session installed) 
    486        * 2. !{@link GM_USE_COOKIE} | {@link GM_USE_PHPSESSION} (if your server have PHP Session installed, and don't want to set browser's cookie) 
    487        * 3. {@link GM_USE_COOKIE} | {@link GM_USE_PHPSESSION} (if your server have PHP Session installed, and would like to use cookie to store session) 
    488        
    489        * @return void 
    490         * @param int $method     
    491        */ 
    492        function setSessionMethod($method) { 
    493                if ($method & GM_USE_PHPSESSION) { 
    494                        if (!extension_loaded('session')) { 
    495                                // Added to gracefully handle multithreaded servers; by Neerav; 8 July 2005 
    496                                if (isset($_ENV["NUMBER_OF_PROCESSORS"]) and ($_ENV["NUMBER_OF_PROCESSORS"] > 1)) { 
    497                                        $this->setSessionMethod(GM_USE_COOKIE | !GM_USE_PHPSESSION);  // forced to use custom cookie 
    498                                        $a = array( 
    499                                                "action"                => "load PHP session extension", 
    500                                                "status"                => "failed", 
    501                                                "message"               => "Using a multithread server. Ensure php_session.dll has been enabled (uncommented) in your php.ini." 
    502                                        ); 
    503                                        array_unshift($this->return_status, $a); 
    504                                        return; 
    505                                } else { 
    506                                        // Changed extension loading; by Neerav; 18 Aug 2005 
    507                                        //if (!dl('php_session.dll') && !dl('session.so')) { 
    508                                        if (dl(((PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '') . 'session.' . PHP_SHLIB_SUFFIX)) { 
    509                                                $a = array( 
    510                                                        "action"                => "load PHP session extension", 
    511                                                        "status"                => "failed", 
    512                                                        "message"               => "unable to load PHP session extension." 
    513                                                ); 
    514