Changeset 12001
- Timestamp:
- 09/04/07 15:35:23 (1 year ago)
- Files:
-
- trunk/midcom/com.magnettechnologies.contactgrabber/contactgrabber.php (modified) (8 diffs)
- trunk/midcom/com.magnettechnologies.contactgrabber/lib/gmail/libgmailer.php (modified) (11 diffs)
- trunk/midcom/com.magnettechnologies.contactgrabber/lib/yahoo/class.GrabYahoo.php (modified) (1 diff)
- trunk/midcom/com.magnettechnologies.contactgrabber/static/js/common.js (modified) (4 diffs)
- trunk/midcom/com.magnettechnologies.contactgrabber/static/styles/elements.css (modified) (1 diff)
- trunk/midcom/com.magnettechnologies.contactgrabber/style/search-form.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/com.magnettechnologies.contactgrabber/contactgrabber.php
r11774 r12001 2 2 3 3 /** 4 * This is some kind of a wrapper for the contactcrabber.5 */4 * This is some kind of a wrapper for the contactcrabber. 5 */ 6 6 7 7 /** 8 * Contact Grabber9 * Version 0.310 * Released 9th May, 200711 * Author: Magnet Technologies, vishal.kothari@magnettechnologies.com12 * Credits: Janak Prajapati, Pravin Shukla, Tapan Moharana13 * Copyright (C) 200714 15 * This program is free software; you can redistribute it and/or16 * modify it under the terms of the GNU General Public License17 * as published by the Free Software Foundation; either version 218 * 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 of22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23 * GNU General Public License for more details.24 25 * You should have received a copy of the GNU General Public License26 * along with this program; if not, write to the Free Software27 * 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 **/ 29 29 30 30 … … 40 40 $this->_component = 'com.magnettechnologies.contactgrabber'; 41 41 parent::midcom_baseclasses_components_purecode(); 42 42 43 43 $_MIDCOM->style->append_component_styledir('com.magnettechnologies.contactgrabber'); 44 44 45 45 $_MIDCOM->add_link_head 46 46 ( … … 49 49 'rel' => 'stylesheet', 50 50 'type' => 'text/css', 51 'href' => MIDCOM_STATIC_URL."/com.magnettechnologies.contactgra per/styles/elements.css",51 'href' => MIDCOM_STATIC_URL."/com.magnettechnologies.contactgrabber/styles/elements.css", 52 52 ) 53 53 ); 54 54 55 55 $_MIDCOM->enable_jquery(); 56 $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/com.magnettechnologies.contactgra per/js/common.js');56 $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/com.magnettechnologies.contactgrabber/js/common.js'); 57 57 } 58 58 … … 64 64 { 65 65 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(); 68 68 } 69 69 … … 71 71 { 72 72 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(); 75 75 } 76 76 … … 78 78 { 79 79 require("lib/orkut/grabOrkut.class.php"); 80 $this->_email = $_POST['username'];80 $this->_email = $_POST['username']; 81 81 $this->_resource_obj = new orkut(); 82 82 } … … 85 85 { 86 86 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") 92 92 { 93 93 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() 111 110 { 112 111 // $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 } 135 135 } 136 136 … … 138 138 { 139 139 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 */ 140 204 } 141 205 } trunk/midcom/com.magnettechnologies.contactgrabber/lib/gmail/libgmailer.php
r11459 r12001 41 41 * @var bool 42 42 */ 43 define("GM_USE_LIB_AS_MODULE", false);// Normal operation43 define("GM_USE_LIB_AS_MODULE", false); // Normal operation 44 44 45 45 /**#@+ … … 47 47 * @var string 48 48 */ 49 define("GM_LNK_GMAIL", "https://mail.google.com/mail/");50 define("GM_LNK_GMAIL_HTTP", "http://mail.google.com/mail/");49 define("GM_LNK_GMAIL", "https://mail.google.com/mail/"); 50 define("GM_LNK_GMAIL_HTTP", "http://mail.google.com/mail/"); 51 51 // Changed by Gan; 10 Sept 2005 52 define("GM_LNK_LOGIN", "https://www.google.com/accounts/ServiceLoginAuth");52 define("GM_LNK_LOGIN", "https://www.google.com/accounts/ServiceLoginAuth"); 53 53 // 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<mpl=yj_blanco<mplcache=2&hl=en");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<mpl=yj_blanco<mplcache=2&hl=en"); 55 55 // 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");56 define("GM_LNK_INVITE_REFER", "https://www.google.com/accounts/ServiceLoginBox?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail"); 57 57 // Updated by Neerav; 22 Aug 2006 58 58 define("GM_USER_AGENT", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6"); … … 61 61 * @deprecated 62 62 */ 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");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"); 68 68 /**#@-*/ 69 69 … … 72 72 * @var int 73 73 */ 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);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); 80 80 /**#@-*/ 81 81 … … 87 87 * Apply label to conversation 88 88 */ 89 define("GM_ACT_APPLYLABEL", 1);89 define("GM_ACT_APPLYLABEL", 1); 90 90 /** 91 91 * Remove label from conversation 92 92 */ 93 define("GM_ACT_REMOVELABEL", 2);93 define("GM_ACT_REMOVELABEL", 2); 94 94 /** 95 95 * Star a conversation 96 96 */ 97 define("GM_ACT_STAR", 3);97 define("GM_ACT_STAR", 3); 98 98 /** 99 99 * Remove a star from (unstar) a conversation 100 100 */ 101 define("GM_ACT_UNSTAR", 4);101 define("GM_ACT_UNSTAR", 4); 102 102 /** 103 103 * Mark a conversation as spam 104 104 */ 105 define("GM_ACT_SPAM", 5);105 define("GM_ACT_SPAM", 5); 106 106 /** 107 107 * Unmark a conversation from spam 108 108 */ 109 define("GM_ACT_UNSPAM", 6);109 define("GM_ACT_UNSPAM", 6); 110 110 /** 111 111 * Mark conversation as read 112 112 */ 113 define("GM_ACT_READ", 7);113 define("GM_ACT_READ", 7); 114 114 /** 115 115 * Mark conversation as unread 116 116 */ 117 define("GM_ACT_UNREAD", 8);117 define("GM_ACT_UNREAD", 8); 118 118 /** 119 119 * Trash a conversation 120 120 */ 121 define("GM_ACT_TRASH", 9);121 define("GM_ACT_TRASH", 9); 122 122 /** 123 123 * Directly delete a conversation 124 124 */ 125 define("GM_ACT_DELFOREVER", 10);125 define("GM_ACT_DELFOREVER", 10); 126 126 /** 127 127 * Archive a conversation 128 128 */ 129 define("GM_ACT_ARCHIVE", 11);129 define("GM_ACT_ARCHIVE", 11); 130 130 /** 131 131 * Move conversation to Inbox 132 132 */ 133 define("GM_ACT_INBOX", 12);133 define("GM_ACT_INBOX", 12); 134 134 /** 135 135 * Move conversation out of Trash 136 136 */ 137 define("GM_ACT_UNTRASH", 13);137 define("GM_ACT_UNTRASH", 13); 138 138 /** 139 139 * Discard a draft 140 140 */ 141 define("GM_ACT_UNDRAFT", 14);141 define("GM_ACT_UNDRAFT", 14); 142 142 /** 143 143 * Trash individual message. 144 144 */ 145 define("GM_ACT_TRASHMSG", 15);145 define("GM_ACT_TRASHMSG", 15); 146 146 /** 147 147 * Untrash (retrieve from trash) individual message. 148 148 * @since 27 Feb 2006 149 149 */ 150 define("GM_ACT_UNTRASHMSG", 18);150 define("GM_ACT_UNTRASHMSG", 18); 151 151 /** 152 152 * Delete spam, forever. 153 153 */ 154 define("GM_ACT_DELSPAM", 16);154 define("GM_ACT_DELSPAM", 16); 155 155 /** 156 156 * Delete trash message, forever. 157 157 */ 158 define("GM_ACT_DELTRASHED", 17);158 define("GM_ACT_DELTRASHED", 17); 159 159 /** 160 160 * Deleted trashed messages from the thread forever. 161 161 * @since 27 Feb 2006 162 162 */ 163 define("GM_ACT_DELTRASHEDMSGS", 19);163 define("GM_ACT_DELTRASHEDMSGS", 19); 164 164 /**#@-*/ 165 165 … … 168 168 */ 169 169 define("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 2005172 define("GM_USE_COOKIE", 0x001);173 define("GM_USE_PHPSESSION", 0x002);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); 174 174 if (!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); 177 177 } 178 178 /**#@-*/ … … 202 202 * @var string 203 203 */ 204 var $cookie_str;205 var $login;206 var $pwd;207 /**208 * Email domain209 *210 * Support for "Gmail for your domain".211 * Domain name of email address to check.212 *213 * @access private214 * @var string215 * @author Neerav216 * @since 8 Jun 2006217 */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 Neerav227 * @since 13 Aug 2005228 */229 var $gmail_data;230 /**231 * Raw packet232 */233 var $raw;234 /**235 * Raw packet for contact list236 */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 names246 */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 public253 * @var bool254 */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 */ 255 255 var $created; 256 256 /** 257 * Status of GMailer258 *259 * If something is wrong, check this class property to see what is260 * going wrong.261 *262 * @author Neerav263 * @since 8 July 2005264 * @var mixed[]265 * @access public266 */267 var $return_status = array();268 269 270 /**271 * Constructor of GMailer272 *273 * During the creation of GMailer object, it will perform several tests to see274 * if the cURL extension is available or not. However,275 * note that the constructor will NOT return false or null even if these tests276 * are failed. You will have to check the class property {@link GMailer::$created} to see if277 * the object "created" is really, uh, created (i.e. working), and property278 * {@link GMailer::$return_status} or method {@link GMailer::lastActionStatus()} to see what was going wrong.279 *280 * Example:281 * <code>282 * <?php283 * $gmailer = new GMailer();284 * if (!$gmailer->created) {285 * echo "Error message: ".$gmailer->lastActionStatus("message");286 * } else {287 * // Do something with $gmailer288 * }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 * 292 292 * A typical usage of GMailer object would be like this: 293 293 * <code> … … 309 309 * } 310 310 * ? > 311 * </code> 312 *313 * @see GMailer::$created, GMailer::$return_status, GMailer::lastActionStatus()314 * @return GMailer315 */316 function GMailer() {317 // GMailer needs "curl" extension to work318 $this->created = true;319 if (!extension_loaded('curl')) {320 // Added to gracefully handle multithreaded servers; by Neerav; 8 July 2005321 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.com355 $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 void373 * @param string $my_login Gmail's login name (without @gmail.com)374 * @param string $my_pwd Password375 * @param float $my_tz Timezone with respect to GMT, but in decimal. For example, -2.5 for -02:30GMT376 */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 2005383 $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 void395 * @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."<mpl=yj_blanco<mplcache=2"; */424 // GFYD urls changed to GAFYD; Neerav; 1 Sept 2006425 $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."<mpl=yj_blanco<mplcache=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 * <?php445 * // proxy server requiring login446 * $gmailer->setProxy("proxy.company.com", "my_name", "my_pwd");447 *448 * // proxy server without login449 * $gmailer->setProxy("proxy2.company.com", "", "");450 * ? >451 * </code>452 * 453 * @return void454 * @param string $host Proxy server's hostname455 * @param string $username User name if login is required456 * @param string $pwd Password if required457 */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 void490 * @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 2005496 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 cookie498 $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 2005507 //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
