[vhffs-dev] [1025] Fixed UTF-8 in mass mailings and in moderation process |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1025
Author: gradator
Date: 2007-10-25 19:00:08 +0000 (Thu, 25 Oct 2007)
Log Message:
-----------
Fixed UTF-8 in mass mailings and in moderation process
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm
trunk/vhffs-panel/admin/moderation_submit.pl
trunk/vhffs-robots/src/mailing.pl
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2007-10-25 16:19:02 UTC (rev 1024)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2007-10-25 19:00:08 UTC (rev 1025)
@@ -258,6 +258,7 @@
{
use MIME::Lite;
use MIME::Base64;
+ use Encode;
my $from = shift;
my $to = shift;
@@ -266,7 +267,9 @@
my $message = shift;
$subject = $mailtag.' '.$subject if( defined $mailtag );
+ $subject = Encode::encode_utf8( $subject );
$subject = '=?UTF-8?B?'.encode_base64( $subject , '' ).'?=';
+ $message = Encode::encode_utf8( $message );
my $msg = new MIME::Lite
From => $from,
Modified: trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm 2007-10-25 16:19:02 UTC (rev 1024)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mailing.pm 2007-10-25 19:00:08 UTC (rev 1025)
@@ -45,7 +45,12 @@
my $request = $main->{'db'}->prepare( $query ) or return -2;
return undef if ( $request->execute() <= 0 );
- return( $request->fetchall_hashref('id_mailing') );
+ my $rows = $request->fetchall_hashref('id_mailing');
+ foreach( keys(%{$rows}) ) {
+ $rows->{$_}->{'message'} = Encode::decode_utf8( $rows->{$_}->{'message'} );
+ $rows->{$_}->{'subject'} = Encode::decode_utf8( $rows->{$_}->{'subject'} );
+ }
+ return $rows;
}
1;
Modified: trunk/vhffs-panel/admin/moderation_submit.pl
===================================================================
--- trunk/vhffs-panel/admin/moderation_submit.pl 2007-10-25 16:19:02 UTC (rev 1024)
+++ trunk/vhffs-panel/admin/moderation_submit.pl 2007-10-25 19:00:08 UTC (rev 1025)
@@ -38,6 +38,7 @@
use CGI;
use CGI::Session;
use strict;
+use Encode;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Panel::Main;
@@ -56,7 +57,7 @@
my $templatedir = $panel->{'templatedir'};
my $accept = $cgi->param('ACCEPT');
-my $reason = $cgi->param('reason');
+my $reason = Encode::decode_utf8( $cgi->param('reason') );
my $template = new HTML::Template( filename => $templatedir.'/panel/admin/misc/moderation_applied.tmpl' );
Modified: trunk/vhffs-robots/src/mailing.pl
===================================================================
--- trunk/vhffs-robots/src/mailing.pl 2007-10-25 16:19:02 UTC (rev 1024)
+++ trunk/vhffs-robots/src/mailing.pl 2007-10-25 19:00:08 UTC (rev 1025)
@@ -29,16 +29,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#This is a part of VHFFS system
-#This is a free software, no commercial use is allowed
-#If you do a commercial use without author's authorisation
-#We will steal your fridge and rape your dog
-
#This bots send mailings to all hosted people
-#Convert mailing from utf8 to perl internal's
-#TODO : Declare an encoding system in the vhffs.conf for mailings
-
use strict;
use utf8;
use lib '%VHFFS_LIB_DIR%';
@@ -49,6 +41,7 @@
use Vhffs::Robots::User;
use Vhffs::Robots;
use Vhffs::Constants;
+binmode STDOUT , ':utf8';
my $vhffs = init Vhffs::Main;
exit 1 unless defined $vhffs;
@@ -65,16 +58,12 @@
foreach my $idm ( keys %{$mailings} )
{
- next unless defined $mailings->{$idm}{message};
- next unless defined $mailings->{$idm}{subject};
+ next unless ( defined $mailings->{$idm}{subject} && defined $mailings->{$idm}{message} );
- my $subject = Vhffs::Functions::stripslashes( $mailings->{$idm}{subject} );
- my $message = Vhffs::Functions::stripslashes( $mailings->{$idm}{message} );
-
foreach my $user ( @{$users} )
{
next unless defined $user;
- Vhffs::Functions::send_mail( $from , $user->get_mail , $vhffs->get_config->get_mailtag , $subject , $message );
+ Vhffs::Functions::send_mail( $from , $user->get_mail , $vhffs->get_config->get_mailtag , $mailings->{$idm}{subject} , $mailings->{$idm}{message} );
}
my $query = "UPDATE vhffs_mailings SET state='".Vhffs::Constants::ACTIVATED."' WHERE id_mailing='".$idm."'";