Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. <?php
  2.  
  3. $_SERVER['HTTP_HOST']="127.0.1.1";
  4.  
  5. include(dirname(__FILE__).'/../../config-defaults.php');
  6.  
  7. global $sessionhandler,$dbprefix,$rootdir,$homedir,$rooturl,$databasetype,$databaseport,$databaselocation,$databasepersistent;
  8.  
  9. $use_firebug_lite="";
  10.  
  11. include(dirname(__FILE__).'/../../common.php');
  12.  
  13. include(dirname(__FILE__).'/../database.php');
  14.  
  15. if(isset(
  16.  
  17. anish();
  18.  
  19. global $connect,$scriptname;
  20.  
  21. $settings=getSurveyInfo($surveyidoriginal);
  22.  
  23. if ($settings['bounceprocessing']=='N')
  24.  
  25. {
  26.  
  27. }
  28.  
  29. else
  30.  
  31. {
  32.  
  33. $bouncetotal=0;
  34.  
  35. $checktotal=0;
  36.  
  37. if($settings['bounceprocessing']=='G')
  38.  
  39. {
  40.  
  41. $accounttype=getGlobalSetting('bounceaccounttype');
  42.  
  43. $hostname=getGlobalSetting('bounceaccounthost');
  44.  
  45. $username=getGlobalSetting('bounceaccountuser');
  46.  
  47. $pass=getGlobalSetting('bounceaccountpass');
  48.  
  49. $hostencryption=getGlobalSetting('bounceencryption');
  50.  
  51. }
  52.  
  53. else
  54.  
  55. {
  56.  
  57. $accounttype=$settings['bounceaccounttype'];
  58.  
  59. $hostname=$settings['bounceaccounthost'];
  60.  
  61. $username=$settings['bounceaccountuser'];
  62.  
  63. $pass=$settings['bounceaccountpass'];
  64.  
  65. $hostencryption=$settings['bounceaccountencryption'];
  66.  
  67. }
  68.  
  69.  
  70.  
  71. if($accounttype=='IMAP')
  72.  
  73. {
  74.  
  75. if($hostencryption=='SSL')
  76.  
  77. {
  78.  
  79. $finalhostname='{'.$hostname.'/imap/ssl}INBOX';
  80.  
  81. }
  82.  
  83. elseif($hostencryption=='TLS')
  84.  
  85. {
  86.  
  87. $finalhostname='{'.$hostname.'/imap/tls}INBOX';
  88.  
  89. }
  90.  
  91. else
  92.  
  93. {
  94.  
  95. $finalhostname='{'.$hostname.'/imap}INBOX';
  96.  
  97. }
  98.  
  99. if(@$mbox=imap_open($finalhostname,$username,$pass))
  100.  
  101. {
  102.  
  103. @$count=imap_num_msg($mbox);
  104.  
  105. $lasthinfo=imap_headerinfo($mbox,$count);
  106.  
  107. $datelc=$lasthinfo->date;
  108.  
  109. $datelcu = strtotime($datelc);
  110.  
  111. $gettimestamp = "select timestamp from ".db_table_name("surveys")." where sid='$surveyidoriginal';";
  112.  
  113. $datelcufiles = $connect->Execute($gettimestamp);
  114.  
  115. $datelcufile = substr($datelcufiles,11);
  116.  
  117. while($datelcu > $datelcufile)
  118.  
  119. {
  120.  
  121. $lasthinfo=imap_headerinfo($mbox,$count);
  122.  
  123. $datelc=$lasthinfo->date;
  124.  
  125. $datelcu = strtotime($datelc);
  126.  
  127. $header = explode("\r\n", imap_body($mbox,$count));
  128.  
  129. foreach ($header as $item)
  130.  
  131. {
  132.  
  133. if (preg_match('/^X-surveyid/',$item))
  134.  
  135. {
  136.  
  137. $surveyid=explode(": ",$item);
  138.  
  139. }
  140.  
  141. if (preg_match('/^X-tokenid/',$item))
  142.  
  143. {
  144.  
  145. $token=explode(": ",$item);
  146.  
  147. if($surveyidoriginal == $surveyid[1])
  148.  
  149. {
  150.  
  151. $bouncequery = "UPDATE ".db_table_name("tokens_$surveyidoriginal")." set emailstatus='bounced' where token='$token[1]';";
  152.  
  153. $anish=$connect->Execute($bouncequery);
  154.  
  155. $bouncetotal++;
  156.  
  157. }
  158.  
  159. }
  160.  
  161. }
  162.  
  163. $count--;
  164.  
  165. $lasthinfo=imap_headerinfo($mbox,$count);
  166.  
  167. $datelc=$lasthinfo->date;
  168.  
  169. $datelcu = strtotime($datelc);
  170.  
  171. $checktotal++;
  172.  
  173. }
  174.  
  175. @$count=imap_num_msg($mbox);
  176.  
  177. $lastcheckedinfo=imap_headerinfo($mbox,$count);
  178.  
  179. $datelcfinal=$lastcheckedinfo->date;
  180.  
  181. $datelcfinalu = strtotime($datelcfinal);
  182.  
  183. $entertimestamp = "update ".db_table_name("surveys")." set timestamp='$datelcfinalu' where sid='$surveyidoriginal';";
  184.  
  185. $executetimestamp = $connect->Execute($entertimestamp);
  186.  
  187. }
  188.  
  189. else
  190.  
  191. {
  192.  
  193. echo "Please check your settings";
  194.  
  195. }
  196.  
  197. }
  198.  
  199. elseif($accounttype='POP')
  200.  
  201. {
  202.  
  203. if($hostencryption=='SSL')
  204.  
  205. {
  206.  
  207. $finalhostname='{'.$hostname.'/pop3/ssl/novalidate-cert}INBOX';
  208.  
  209. }
  210.  
  211. elseif($hostencryption=='TLS')
  212.  
  213. {
  214.  
  215. $finalhostname='{'.$hostname.'/pop3/tls/novalidate-cert}INBOX';
  216.  
  217. }
  218.  
  219. else
  220.  
  221. {
  222.  
  223. $finalhostname='{'.$hostname.'/pop3/novalidate-cert}INBOX';
  224.  
  225. }
  226.  
  227. if(@$mbox=imap_open($finalhostname,$username,$pass))
  228.  
  229. {
  230.  
  231. @$count=imap_num_msg($mbox);
  232.  
  233. while($count>0)
  234.  
  235. { @$header = explode("\r\n", imap_body($mbox,$count));
  236.  
  237. foreach ($header as $item)
  238.  
  239. {
  240.  
  241. if (preg_match('/^X-surveyid/',$item))
  242.  
  243. {
  244.  
  245. $surveyid=explode(": ",$item);
  246.  
  247. }
  248.  
  249. if (preg_match('/^X-tokenid/',$item))
  250.  
  251. {
  252.  
  253. $token=explode(": ",$item);
  254.  
  255. if($surveyidoriginal == $surveyid[1])
  256.  
  257. {
  258.  
  259. $bouncequery = "UPDATE ".db_table_name("tokens_$surveyidoriginal")." set emailstatus='bounced' where token='$token[1]';";
  260.  
  261. $anish=$connect->Execute($bouncequery) or safe_die ("Couldn't update sent field<br />$query<br />".$connect->ErrorMsg());
  262.  
  263. $bouncetotal++;
  264.  
  265. }
  266.  
  267. }
  268.  
  269. }
  270.  
  271. $count--;
  272.  
  273. $checktotal++;
  274.  
  275. }
  276.  
  277. imap_errors();
  278.  
  279. imap_close($mbox);
  280.  
  281. }
  282.  
  283. else
  284.  
  285. {
  286.  
  287. echo "Please check your settings";
  288.  
  289. }
  290.  
  291. }
  292.  
  293. if($bouncetotal>0)
  294.  
  295. {
  296.  
  297. echo "<div id='dialog-modal'>$checktotal messages were scanned out of which $bouncetotal were marked as bounce by the system. <br><br><br>Please reload the browse table to view results</div>";
  298.  
  299. }
  300.  
  301. else
  302.  
  303. {
  304.  
  305.  
  306.  
  307. echo "<div id ='dialog-modal'>$checktotal messages were scanned out of which $bouncetotal were marked as bounce by the system.</div>";
  308.  
  309.  
  310.  
  311. }
  312.  
  313. }
  314.  
  315.  
  316.  
  317.  
  318.  
  319. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement