View Single Post
  #7  
Old 14th March 2012, 10:15
tio289 tio289 is offline
Member
 
Join Date: Mar 2009
Posts: 70
Thanks: 2
Thanked 14 Times in 9 Posts
Default

Fixed PHP script (I add full path to postmap command because cron not found it) :

PHP Code:
<?php

$link 
mysql_connect('s0.ikfsystems.sk''map_relay''RRhQe8qa4Qhmezeq'falseMYSQL_CLIENT_SSL);

if(!
$link) die;

mysql_select_db('dbispconfig'$link);

$result mysql_query('SELECT `domain` FROM `mail_domain` WHERE `active` = "y"');
create_map($result'domain''/etc/postfix/relay_domains');

$result mysql_query('SELECT `source` FROM `mail_forwarding` WHERE `active` = "y"');
create_map($result'source''/etc/postfix/relay_recipients');

$result mysql_query('SELECT `email` FROM `mail_user` WHERE `disabledeliver` = "n"');
create_map($result'email''/etc/postfix/relay_recipients''a');

exec('/usr/sbin/postmap hash:/etc/postfix/relay_domains & /usr/sbin/postmap hash:/etc/postfix/relay_recipients');

function 
create_map($result$key$file$type 'w')
{
        if(
mysql_num_rows($result) == 0)return false;
        
        
$content '';
        
        while(
$row mysql_fetch_array($result))
        {
                
$content .= $row[$key]."\tOK\n";
        }
        
        
write_file($file$content$type);
}

function 
write_file($file$content$type 'w')
{
        
$handle fopen($file$type);
        
fwrite($handle$content);
        
fclose($handle);
        
        return;
}
__________________
Independent Senior Webdeveloper
Reply With Quote