Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #21  
Old 28th May 2010, 22:48
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

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.
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
Sponsored Links
  #22  
Old 28th May 2010, 22:51
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,771
Thanks: 821
Thanked 5,331 Times in 4,183 Posts
Default

Quote:
Character encoding? Just a thought.
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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #23  
Old 28th May 2010, 22:59
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

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
File Type: txt mail_content_filters.csv.txt (50.4 KB, 196 views)
File Type: txt mail_content_filters.php.txt (1.4 KB, 194 views)
File Type: txt mail_content_filters.sh.txt (72 Bytes, 202 views)
__________________
System6Hosting.com, ISPConfig 3, Debian.

Last edited by BorderAmigos; 28th May 2010 at 23:13.
Reply With Quote
The Following 2 Users Say Thank You to BorderAmigos For This Useful Post:
ajhart (14th February 2011), till (28th May 2010)
  #24  
Old 29th May 2010, 16:23
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

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
File Type: txt mail_content_filters.csv.txt (54.1 KB, 184 views)
__________________
System6Hosting.com, ISPConfig 3, Debian.

Last edited by BorderAmigos; 29th May 2010 at 18:51.
Reply With Quote
The Following User Says Thank You to BorderAmigos For This Useful Post:
ajhart (14th February 2011)
  #25  
Old 9th June 2010, 21:16
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

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.
__________________
System6Hosting.com, ISPConfig 3, Debian.

Last edited by BorderAmigos; 9th June 2010 at 21:18.
Reply With Quote
  #26  
Old 18th June 2010, 16:08
wxman wxman is offline
Senior Member
 
Join Date: May 2007
Posts: 189
Thanks: 11
Thanked 2 Times in 2 Posts
Default

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 by wxman; 27th June 2010 at 01:55.
Reply With Quote
  #27  
Old 14th February 2011, 14:48
ajhart ajhart is offline
Junior Member
 
Join Date: Jun 2009
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
Default 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:

Quote:
if($diff_num > 0) {
//print_r($diff_num);
//print_r($diffrec_full);
$diffstr = $app->db->quote(serialize($diffrec_full));
$username = $app->db->quote($_SESSION['s']['user']['username']);
$dbidx = $primary_field.':'.$primary_id;
This would rock my world is this works or I can do 641 entries manually
Thanks in advance
__________________
SYSTEM FAILURE
Resistance is futile
Reply With Quote
  #28  
Old 24th October 2012, 19:20
abdi abdi is offline
Senior Member
 
Join Date: Sep 2012
Posts: 118
Thanks: 0
Thanked 10 Times in 6 Posts
Default

Quote:
Originally Posted by till View Post
The ISPConfig mysql library is here:

/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php

Your php script should look like this (untested, partly pseudo code):

Code:
<?php

include_once('/usr/local/ispconfig/interface/lib/config.inc.php');
include_once('/usr/local/ispconfig/interface/lib/classes/db_mysql.inc.php');

$db = new db;

$tablename = "database_table_name";
$insert_data = "(a,b,c) values ('a','b','c')";
$index_field = "dbtable_index_field_name";

$db->datalogInsert($tablename, $insert_data, $index_field);

?>
The content of the variables has to be changed to match the data and table that you want to modify.
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 ...)
Reply With Quote
  #29  
Old 24th October 2013, 14:32
Zappodrom Zappodrom is offline
Junior Member
 
Join Date: Oct 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

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 Code:
<?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?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sarg issue while generating reports for squid mail4vij Server Operation 3 31st December 2009 13:12
Ubuntu Server, ISPConfig, Domain name, and problems NYCSavage Server Operation 5 27th November 2009 17:45
Google Apps dayjahone General 19 29th March 2008 17:25
Unable send receive emails vassilis3 Installation/Configuration 15 19th May 2007 14:34
No SPF record. beryl Installation/Configuration 6 17th May 2007 19:52


All times are GMT +2. The time now is 04:06.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.