PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/hypervm/httpdocs/htmllib/lib/pserver/driver/mailqueue__qmaillib.php

https://github.com/yourhty/hypervm
PHP | 123 lines | 92 code | 27 blank | 4 comment | 13 complexity | fc00127276c885e0f8212a5681b76025 MD5 | raw file
  1. <?php
  2. class mailqueue__qmail extends lxDriverClass {
  3. static function QueueFlush()
  4. {
  5. lxshell_return("pkill", "-14", "-f", "qmail-send");
  6. }
  7. static function QueueDelete($list)
  8. {
  9. global $gbl, $sgbl, $login, $ghtml;
  10. foreach($list as $f) {
  11. $string[] = "-d$f";
  12. }
  13. $string = implode(" ", $string);
  14. lxfile_unix_chmod("__path_program_root/bin/misc/qmHandle", "0755");
  15. exec_with_all_closed("$sgbl->__path_program_root/bin/misc/qmHandle $string");
  16. }
  17. static function readSingleMail($name)
  18. {
  19. $ret['message'] = lxshell_output("__path_program_root/bin/misc/qmHandle", "-m$name");
  20. $oldtime = time() - 7200;
  21. $newtime = time() - 500;
  22. $fp = fopen("/var/log/kloxo/maillog", "r");
  23. $fsize = lxfile_size("/var/log/kloxo/maillog");
  24. $ot = date("Y-m-d:H-i");
  25. dprint("Start time: $ot\n");
  26. $res = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("mailtraffic", "getTimeFromOriginalQmailString"));
  27. if ($res < 0) {
  28. $ret['log'] = null;
  29. return $ret;
  30. }
  31. //$s = fgets($fp);
  32. dprint("here $s\n");
  33. takeToStartOfLine($fp);
  34. takeToStartOfLine($fp);
  35. //$s = fgets($fp);
  36. dprint("here $s\n");
  37. $delivery = null;
  38. while (!feof($fp)) {
  39. $s = fgets($fp);
  40. if (!$delivery) {
  41. if (csa($s, "starting delivery") && csa($s, "msg $name")) {
  42. $delivery = preg_replace("/.*delivery ([^:]*):.*/", "$1", $s);
  43. $delivery = trim($delivery);
  44. dprint("Deliver num: $delivery*\n");
  45. continue;
  46. }
  47. } else {
  48. dprint("$s\n");
  49. if (csa($s, "delivery $delivery:")) {
  50. dprint("$s\n");
  51. $ret['log'] = $s;
  52. break;
  53. }
  54. }
  55. }
  56. return $ret;
  57. }
  58. static function readMailqueue()
  59. {
  60. lxfile_unix_chmod("__path_program_root/bin/misc/qmHandle", "0755");
  61. $res = lxshell_output("__path_program_root/bin/misc/qmHandle", "-l");
  62. $list = array('subject', 'to', 'from', 'date', 'size');
  63. //$res = lfile_get_contents("a.txt");
  64. $res = explode("\n", $res);
  65. //dprintr($res);
  66. $i = 0;
  67. foreach($res as $r) {
  68. $r = trim($r);
  69. if (!$r) {
  70. $i++;
  71. continue;
  72. }
  73. if (is_numeric($r[0])) {
  74. list($nname, $s, $ss) = explode(" ", $r);
  75. $ret[$i]['nname'] = $nname;
  76. if (cse($ss, 'R)')) {
  77. $ret[$i]['type'] = 'remote';
  78. } else {
  79. $ret[$i]['type'] = 'local';
  80. }
  81. continue;
  82. }
  83. foreach($list as $l) {
  84. $ul = ucfirst($l);
  85. if (csb($r, "$ul:")) {
  86. $ret[$i][$l] = strfrom($r, "$ul:");
  87. if ($l === 'size') {
  88. $ret[$i][$l] = strtil($ret[$i][$l], " bytes");
  89. $ret[$i][$l] = trim($ret[$i][$l]);
  90. }
  91. }
  92. }
  93. }
  94. return $ret;
  95. }
  96. }