Bulk add DNS Records

Discussion in 'Installation/Configuration' started by flevoict, Mar 25, 2010.

  1. BorderAmigos

    BorderAmigos New Member

    The data is being imported with active as a lower case y. If I manually activate it and then deactivate it it turns to an n.

    When imported it looks like just a y in phpMyAdmin but neither the green check nor the red x show in ISPConfig3 so it's being seen as something else. Character encoding? Just a thought.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Very unlikely as the character 'y' is the same in all encodings.

    Change the column type of the active column to varchar 1, then import again and check with phpmyadmin which value is in the db.
     
  3. BorderAmigos

    BorderAmigos New Member

    Something invisible was sneaking in at the end of the line in the .csv file, a new line or line return maybe. I added a comma at the end so the explode would add the line end to a different unused array element and now they are all active when imported. I'm editing on a Windows machine but the editor is set for Unix format. Who knows? Works well know.

    Attached are the 3 working files. Put them all in the same directory, remove the .txt extension, set the .sh file as executable and run it as root.

    Thanks again Till.


    PS - It takes a minute for the ISPConfig 3 server to write out the postfix check files from the database. So wait a few minutes to test after installing the filters.
     

    Attached Files:

    Last edited: May 28, 2010
  4. BorderAmigos

    BorderAmigos New Member

    There are a couple filters in the previous .csv file corrupted with extra double quotes. All or most are fixed in the attached file here.

    To get ISPConfig 3 to write the /etc/postfix/*_checks files you first have to erase or rename the existing ones, then thru the ISPConfig interface you need to change and save a filter. Deactivate one, save, activate it again, save... works.

    With the above filters and the below added to /etc/postfix/main.cf I am getting no spam. Between 600 to 1000 a day rejected. All non-spam seems to be getting through ok.
    Code:
    # Some spam blocking measures
    disable_vrfy_command = yes
    smtpd_delay_reject = yes
    smtpd_helo_required = yes
    smtpd_helo_restrictions = 
       permit_mynetworks,
       reject_non_fqdn_hostname,
       reject_invalid_hostname,
       permit
    smtpd_recipient_restrictions =
       permit_mynetworks,
       permit_sasl_authenticated,
       check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf,
       reject_unauth_destination,
       reject_rbl_client sbl.spamhaus.org,
       reject_rbl_client cbl.abuseat.org,
       reject_rbl_client dul.dnsbl.sorbs.net,
       permit
    
     

    Attached Files:

    Last edited: May 29, 2010
  5. BorderAmigos

    BorderAmigos New Member

    Follow up... Some of the filters are malformed and should be fixed or deleted. Also, some of them are rejecting valid emails. For example: /^From:.*@.*.lb/ is rejecting mail from domain blalb.com which is valid for me (should be /^From:.*@.*\.lb/ ). Advice is to set them to WARN rather than reject and monitor mail logs to see which ones you need to fix.
     
    Last edited: Jun 9, 2010
  6. wxman

    wxman New Member

    Thanks for all the work on this.
    I gave it a try by uploading the three files to my /tmp/ dir on my linux server. I set the .sh file to execute, but this is what I got:
    Code:
    root@web1:/tmp# sh mail_content_filters.sh
    PHP Warning: Module 'apc' already loaded in Unknown on line 0
    PHP Fatal error: Call to a member function quote() on a non-object in /usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php on line 280
    
     
    Last edited: Jun 27, 2010
  7. ajhart

    ajhart New Member

    PHP Error

    Big Thanks to Till and BorderAmigos.

    I also get a php error when executing the mail_content_filters.sh file:
    Running Fedora14 with ISPConfig 3.0.3.2 stable

    [root@server mail_filter_content]# ./mail_content_filters.sh
    PHP Fatal error: Call to a member function quote() on a non-object in /usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php on line 279


    Here is my line 279:

    This would rock my world is this works :D or I can do 641 entries manually :confused:
    Thanks in advance
     
  8. abdi

    abdi Member

    If the ISP master server is different from the server hosting the script how is it possible to include those files or use them to manipulate the database ...

    Which 3 or more files should i copy to the script server (I know i need to adjust the config with database connection settings ...)
     
  9. Zappodrom

    Zappodrom New Member

    Hi,

    sorry for replying on this old thread. But I've tried to implement the above filters using the scripts! When I run the mail_conten_filters.sh I get the following error:

    PHP Fatal error: Call to a member function datalogInsert() on a non-object in /tmp/mail_content_filters.php on line 36

    My Script looks like this:

    PHP:
    <?php
    global $app,$conf,$db;

    include(
    '/usr/local/ispconfig/interface/lib/config.inc.php');
    $conf['start_session'] = false;
    include(
    '/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php');

    $db 'dbispconfig';
    $tablename "mail_content_filter";  // I emptied this table first using phpMyAdmin
    $index_field "content_filter_id";

    print 
    "Running...<br>\n";
    $dataFile fopen("./mail_content_filters.csv""rb");

    while (!
    feof($dataFile) ) {
    $mailFilters fgets($dataFile);
    $dVal explode(','$mailFilters);
    /*
    $dVal[0] = utf8_encode($dVal[0]);
    $dVal[1] = utf8_encode($dVal[1]);
    $dVal[2] = utf8_encode($dVal[2]);
    $dVal[3] = utf8_encode($dVal[3]);
    $dVal[4] = utf8_encode($dVal[4]);
    $dVal[5] = utf8_encode($dVal[5]);
    $dVal[6] = utf8_encode($dVal[6]);
    $dVal[7] = utf8_encode($dVal[7]);
    $dVal[8] = utf8_encode($dVal[8]);
    $dVal[9] = utf8_encode($dVal[9]);
    $dVal[10] = utf8_encode($dVal[10]);
    $dVal[11] = utf8_encode($dVal[11]);
    */
    $insert_data "(sys_userid,sys_groupid,sys_perm_user,sys_perm_group,sys_perm_other,server_id,type,pattern,data,action,active)";
    $insert_data .= " values ";
    $insert_data .= "('$dVal[1]','$dVal[2]','$dVal[3]','$dVal[4]','$dVal[5]','$dVal[6]','$dVal[7]','$dVal[8]','$dVal[9]','$dVal[10]','$dVal[11]')";
    print 
    $insert_data.'   ';
    $db->datalogInsert($tablename$insert_data$index_field);
    }
    fclose($dataFile);
    print 
    " Finished!<br>\n";
    ?>
    The Logfile from the script shows the following message:

    Code:
    Running...<br>
    (sys_userid,sys_groupid,sys_perm_user,sys_perm_group,sys_perm_other,server_id,type,pattern,data,action,active) values ('1','1','riud','riud','','1','body','/^(Content-Type:.*|\s+)charset\s*=\s*?(big5|euc-kr|gb2312|koi8|ks_c_5601-1987|Windows-1251)?/','(mcf) No foreign character sets please.','REJECT','y')
    Can someone tell me what went wrong here?
     

Share This Page