LogicWeb: Contact Importer Help

Reply

Join Date: Jan 2008
Posts: 39
Reputation: LogicWeb is an unknown quantity at this point 
Solved Threads: 0
LogicWeb LogicWeb is offline Offline
Light Poster

LogicWeb: Contact Importer Help

 
0
  #1
Oct 4th, 2008
Good day everyone.

I purchased Octazen contact importer script and trying to customize the sent emails to use html, but I cannot figure out exactly how to go about this process since the main file importer.php is mixed with php and html, and the actual form fields and the send-out message.

This is the entire file code

  1. <?php
  2. /********************************************************************************
  3. Sample application
  4.  
  5. Copyright 2006 Octazen Solutions
  6. All Rights Reserved
  7.  
  8. WWW: http://www.octazen.com
  9. Email: support@octazen.com
  10. Version: 1.1
  11. Date: 12/08/2006
  12. ********************************************************************************/
  13. include_once("abimporter/abi.php");
  14.  
  15. error_reporting(E_ALL);
  16.  
  17. if (file_exists("recaptchalib.php")) include_once("recaptchalib.php");
  18. //To use recaptcha, please define the variables $publickey and $privatekey
  19. if (file_exists("recaptchakeys.php")) include_once("recaptchakeys.php");
  20. //$publickey = "...";
  21. //$privatekey = "...";
  22.  
  23. //Allow script to run for up to 90 seconds
  24. set_time_limit (90);
  25.  
  26. $email = isset($_REQUEST['email']) ? $email=$_REQUEST['email'] : '';
  27. $pass = isset($_REQUEST['password']) ? $pass=$_REQUEST['password'] : '';
  28. $contactlist = null;
  29. $errmsg = '';
  30. if (!isset($email)) $email='';
  31. if (!isset($pass)) $pass='';
  32. if (isset($_REQUEST['sendInvite']) && $_REQUEST['sendInvite']='Send invite' && isset($_REQUEST['emails'])) {
  33.  
  34. $host = $_SERVER['HTTP_HOST'];
  35. //Disable email delivery if tested from xxx.octazen.com
  36. if (!empty($host) && strpos(strtolower($host),"octazen.com")>0) {
  37. echo "<div style='font-size: 20px; color:#FF0000'>Email sending disabled in demo</div><br/>\r\n";
  38. }
  39. else {
  40. ////////////////////////////////////////////////////////
  41. //THIS IS THE SECTION TO SEND INVITES AN EMAIL. CUSTOMIZE TO FIT YOUR NEEDS!
  42. ////////////////////////////////////////////////////////
  43. $emails = $_REQUEST['emails'];
  44. $subject = "Invitation from $email";
  45. $headers = 'From: '.$email;
  46. $emails = $_REQUEST['emails'];
  47. foreach ($emails as $to) {
  48. list($to,$name) = split(':::',$to,2);
  49. $message = "Hi $name, This is $email and I'm inviting you to join us at this awesome Christian site! http://www.talkjesus.com\r\n\r\n";
  50. //echo "[TO=$to,SUBJECT=$subject,HEADER=$headers,MESSAGE=$message]";
  51. mail($to, $subject, $message, $headers);
  52. echo "Mail sent to $name ($to)<br/>\r\n";
  53. }
  54. }
  55.  
  56. }
  57. else if (isset($_REQUEST['post'])) {
  58.  
  59. ////////////////////////////////////////////////////////
  60. //THIS IS THE SECTION TO IMPORT CONTACTS
  61. ////////////////////////////////////////////////////////
  62. $validCaptcha = true;
  63. if (function_exists('recaptcha_check_answer') && isset($privatekey)) {
  64. if ($_POST["recaptcha_response_field"]) {
  65. $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"],
  66. $_POST["recaptcha_challenge_field"],
  67. $_POST["recaptcha_response_field"]);
  68. $validCaptcha = $resp->is_valid;
  69. }
  70. else {
  71. $validCaptcha = false;
  72. }
  73. }
  74.  
  75. if ($validCaptcha) {
  76. $obj = new AddressBookImporter;
  77. $res = $obj->fetchContacts($email,$pass);
  78.  
  79. if ($res==_ABI_AUTHENTICATION_FAILED) {
  80. $errmsg='Bad user name or password';
  81. }
  82. else if ($res==_ABI_FAILED) {
  83. $errmsg='Server error';
  84. }
  85. else if ($res==_ABI_UNSUPPORTED) {
  86. $errmsg='Unsupported webmail';
  87. }
  88. else if ($res==_ABI_CAPTCHA_RAISED) {
  89. $errmsg='Captcha challenge was raised during login';
  90. }
  91. else if ($res==_ABI_USER_INPUT_REQUIRED) {
  92. echo 'Need to answer some questions in the webmail service';
  93. }
  94. else if (is_array($res)) {
  95. $contactlist = $res;
  96. $contactlist = abi_dedupe_contacts_by_email($contactlist);
  97. $contactlist = abi_sort_contacts_by_name($contactlist);
  98. }
  99. else {
  100. $errmsg='Unknown error';
  101. }
  102. } else {
  103. //set the error code so that we can display it
  104. $errmsg="Please enter a valid answer to the captcha challenge";
  105. }
  106.  
  107. ////////////////////////////////////////////////////////
  108. }
  109.  
  110. if (function_exists('recaptcha_check_answer') && isset($privatekey) && isset($privatekey)) {
  111. $captchaHtml = recaptcha_get_html($publickey);
  112. }
  113. else {
  114. $captchaHtml = '';
  115. }
  116. ?>
  117. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  118. <html xmlns="http://www.w3.org/1999/xhtml">
  119. <head>
  120. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  121. <title>Contacts Importer</title>
  122. <style type="text/css">
  123. <!--
  124. body,td,th {
  125. font-family: Arial, Helvetica, sans-serif;
  126. font-size: 12px;
  127. color: #4D528A;
  128. }
  129. h1 {
  130. border-top-width: 0px;
  131. border-right-width: 0px;
  132. border-bottom-width: 1px;
  133. border-left-width: 0px;
  134. border-top-style: solid;
  135. border-right-style: solid;
  136. border-bottom-style: solid;
  137. border-left-style: solid;
  138. border-top-color: #FF0000;
  139. border-right-color: #FF0000;
  140. border-bottom-color: #FF0000;
  141. border-left-color: #FF0000;
  142. }
  143. .table {
  144. font-family: Arial, Helvetica, sans-serif;
  145. font-size: 12px;
  146. background-color: #FFFFFF;
  147. border-top-width: 1px;
  148. border-right-width: 0px;
  149. border-bottom-width: 0px;
  150. border-left-width: 1px;
  151. border-top-style: solid;
  152. border-right-style: solid;
  153. border-bottom-style: solid;
  154. border-left-style: solid;
  155. border-top-color: #DFDFDF;
  156. border-right-color: #DFDFDF;
  157. border-bottom-color: #DFDFDF;
  158. border-left-color: #DFDFDF;
  159. }
  160. .table th {
  161. background-color: #C0C0C0;
  162. border-top-width: 1px;
  163. border-right-width: 1px;
  164. border-bottom-width: 1px;
  165. border-left-width: 1px;
  166. border-top-style: solid;
  167. border-right-style: solid;
  168. border-bottom-style: solid;
  169. border-left-style: solid;
  170. border-top-color: #DFDFDF;
  171. border-right-color: #999999;
  172. border-bottom-color: #999999;
  173. border-left-color: #DFDFDF;
  174. margin: 0px;
  175. padding: 2px 10px;
  176. }
  177. .table td {
  178. border-top-width: 0px;
  179. border-right-width: 1px;
  180. border-bottom-width: 1px;
  181. border-left-width: 0px;
  182. border-top-style: solid;
  183. border-right-style: solid;
  184. border-bottom-style: solid;
  185. border-left-style: solid;
  186. border-right-color: #CCCCCC;
  187. border-bottom-color: #CCCCCC;
  188. margin: 0px;
  189. padding: 2px 10px;
  190. vertical-align: top;
  191. }
  192. #footer {
  193. font-size: 11px;
  194. color: #666666;
  195. text-align: right;
  196. padding-top: 3px;
  197. padding-right: 0px;
  198. padding-bottom: 0px;
  199. padding-left: 0px;
  200. border-top-width: 1px;
  201. border-right-width: 0px;
  202. border-bottom-width: 0px;
  203. border-left-width: 0px;
  204. border-top-style: solid;
  205. border-right-style: none;
  206. border-bottom-style: none;
  207. border-left-style: none;
  208. border-top-color: #CCCCCC;
  209. border-right-color: #CCCCCC;
  210. border-bottom-color: #CCCCCC;
  211. border-left-color: #CCCCCC;
  212. margin-top: 10px;
  213. margin-right: 0px;
  214. margin-bottom: 0px;
  215. margin-left: 0px;
  216. }
  217. .style1 {
  218. margin-left: 0px;
  219. }
  220. -->
  221. </style>
  222. </head>
  223.  
  224. <body>
  225. <h1>Contacts Importer</h1>
  226. <form name="f1" action="" method="post">
  227. <table>
  228. <input type="hidden" name="post" value="1" />
  229. <tr valign="top">
  230. <td><div align="right"><strong> Your email address</strong></div></td>
  231. <td> <input name="email" type="text" size="40" value="<?php echo htmlentities($email) ?>" tabindex="1"/>
  232. <br />
  233. For LinkedIn accounts, add &quot;.linkedin&quot; behind your email address (eg. myemail@gmail.com.linkedin).
  234. <br />
  235. For Plaxo accounts, add &quot;.plaxo&quot; behind your email address (eg. myemail@gmail.com.plaxo). <br />
  236. For Google Apps accounts, add &quot;.gmail&quot; behind your email address (eg. myemail@mydomain.com.gmail)<br />
  237. </td>
  238. <td rowspan="5">
  239. <p><strong>Webmails Supported</strong></p>
  240. <ul>
  241. <li>Hotmail</li>
  242. <li>MSN.com</li>
  243. <li>Gmail</li>
  244. <li>Yahoo</li>
  245. <li>AOL</li>
  246. <li>Lycos</li>
  247. <li>Mail.com, </li>
  248. <li>Rediffmail</li>
  249. <li>Indiatimes</li>
  250. <li>IcqMail <br />
  251. </li>
  252. </ul>
  253. <ul>
  254. <li>Outlook CSV</li>
  255. <li>Outlook Express CSV</li>
  256. <li>Thunderbird CSV</li>
  257. <li class="style1">Thunderbird LDIF </li>
  258. </ul>
  259.  
  260. </td></tr>
  261. <tr valign="top">
  262. <td><div align="right"><strong> Password</strong></div></td>
  263. <td>
  264. <input name="password" type="password" id="password" size="40" value="<?php echo htmlentities($pass) ?>" tabindex="2"/>
  265. (Will not be saved)
  266. </td>
  267. </tr>
  268. <tr valign="top">
  269. <td>&nbsp;</td>
  270. <td>
  271. <?php echo $captchaHtml ?>
  272. <input type="submit" name="Submit" value="Fetch" tabindex="3" /></td>
  273. </tr>
  274. <tr valign="top">
  275. <td></td>
  276. <td><p><a href="importercsv.php"><br />
  277. </a>[ <a href="importercsv.php">I want to import Outlook/Outlook Express/Thunderbird CSV/LDIF instead</a> ] </p>
  278. </td>
  279. </tr>
  280. <tr valign="top">
  281. <td></td>
  282. <td><strong><font color="#FF0000" size="3"><?php echo htmlentities($errmsg) ?></font></strong></td>
  283. </tr>
  284. </table>
  285. <?php
  286. ////////////////////////////////////////////////////////
  287. //PRINT OUT TABLE OF RETRIEVED CONTACTS
  288. ////////////////////////////////////////////////////////
  289. if (isset($contactlist)) {
  290. ?>
  291. <script>
  292. function toggleAll(cb) {
  293. var val = cb.checked;
  294. var frm = document.f1;
  295. var len = frm.elements.length;
  296. var i=0;
  297. for( i=0 ; i<len ; i++) {
  298. if (frm.elements[i].name=='emails[]') {
  299. frm.elements[i].checked=val;
  300. }
  301. }
  302. }
  303. </script>
  304. <table border="0" cellspacing="0" cellpadding="0" class="table">
  305. <tr>
  306. <th scope="col"><input type="checkbox" name="checkall" onclick="toggleAll(this)"/></th>
  307. <th scope="col">Name</th>
  308. <th scope="col">Email</th>
  309. </tr>
  310. <?php
  311. $n = count($contactlist);
  312. for ($i=0; $i<$n; $i++) {
  313. $contact = $contactlist[$i];
  314. $name = $contact->name;
  315. $email = $contact->email;
  316. ?>
  317. <tr>
  318. <td><input type="checkbox" name="emails[]" value="<?php echo htmlentities($email).':::'.htmlentities($name) ?>" /></td>
  319. <td><?php echo htmlentities($name, ENT_COMPAT,'UTF-8') ?></td>
  320. <td><?php echo htmlentities($email) ?></td>
  321. </tr>
  322. <?php
  323. }
  324. ?>
  325. </table>
  326. <input type="submit" name="sendInvite" value="Send invite" />
  327. <?php
  328. }
  329. ?>
  330.  
  331. <p>&nbsp;</p>
  332. </form>
  333. </body>
  334. </html>

Unfortunately the Octazen support team is as good as nothing and won't provide anything but a "try another mailer" response. Lame if you ask me.

Line 49 is the main sent out message

  1. $message = "Hi $name, This is $email and I'm inviting you to join us at this awesome Christian site! http://www.talkjesus.com\r\n\r\n";

I'm trying to use html instead, but I cannot figure out how to apply this without screwing up the code.

Thanks in advance for your help.
Talk Jesus Forums [ Over 100 Fulfilled Prophecies in the Bible: click here ]
.....................................................................................
LogicWeb...a smart web solution [ hosting for personal and business since 2004 ]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC