Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

emailconfig.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/php -q
  2. <?PHP
  3. chdir('/home/utd/control');
  4. require_once('lib/database.php');
  5. // Build the vmaildomains file
  6. $fh = fopen('/etc/postfix/vmaildomains','w');
  7. $sql = 'SELECT DISTINCT(domain_name) FROM email NATURAL JOIN domains';
  8. $res = mysql_query($sql);
  9. while ($row = mysql_fetch_assoc($res)) {
  10. fputs($fh, $row['domain_name']."\tplaceholder\n");
  11. }
  12. fclose($fh);
  13. // Build the vmailbox file
  14. $fh = fopen('/etc/postfix/vmailbox','w');
  15. $sql = 'SELECT email_user, e.domain_name AS ed, mailbox_user, m.domain_name AS md FROM ';
  16. $sql .= 'email, mailboxes, domains AS e, domains AS m WHERE mailboxes.mailbox_id = email.mailbox_id AND ';
  17. $sql .= 'e.domain_id = email.domain_id AND m.domain_id = mailboxes.domain_id';
  18. $res = mysql_query($sql);
  19. while ($row = mysql_fetch_assoc($res)) {
  20. if ($row['email_user'] == '%') { $row['email_user'] = ''; }
  21. fputs($fh,$row['email_user'].'@'.$row['ed']."\t".$row['md'].'/'.$row['mailbox_user']."\n");
  22. }
  23. fclose($fh);
  24. // And write the password file
  25. $sql = 'SELECT mailbox_user, mailbox_password, domain_name FROM mailboxes NATURAL JOIN domains';
  26. $res = mysql_query($sql);
  27. $fhs = array();
  28. while ($row = mysql_fetch_array($res)) {
  29. $dir = $row['domain_name'];
  30. if (!is_dir('/etc/virtual/'.$dir)) {
  31. mkdir('/etc/virtual/'.$dir);
  32. }
  33. if (!isset($fhs[$dir])) {
  34. $fhs[$dir] = fopen('/etc/virtual/'.$dir.'/passwd','w');
  35. }
  36. fputs($fhs[$dir],$row['mailbox_user'].':'.$row['mailbox_password']."\n");
  37. }
  38. foreach ($fhs as $fh) { fclose($fh); }
  39. $sql = 'INSERT INTO actions (action_type, action_value, user_id) VALUES (\'restart\', \'postfix\', 5)';
  40. mysql_query($sql);
  41. ?>