File: setupfriendly.pl

package info (click to toggle)
pronto 2.4.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,112 kB
  • ctags: 488
  • sloc: perl: 22,159; makefile: 140; sh: 34; sql: 7
file content (45 lines) | stat: -rwxr-xr-x 1,194 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w

##############################################################################
#
#	13to14.pl	-	This program updates the database to the
#				1.4 format from the 1.3.5 format
#
#	Author		-	Steve Kordik <countzero@cyberdeck.org>
#
#
##############################################################################

BEGIN {
	$libpath = $0;
	$libpath =~ s!/[^/]+$!!;
	$libpath =~ s!/bin$!/lib/cscmail!;
	if (! -e $libpath) { die "Can't find required files in $libpath"; };
}

use lib "$libpath";
use lib "$libpath/modules/lib/perl5/site_perl/5.005";
use DBI;

require 'csclib.pl';
&read_prefs;

my $dbh=&open_db_conn;

$sql2= "update messages set sentto = ?, sentfrom= ?, friendly = ? where id
= ?";
$query2=$dbh->prepare($sql2);

$sql = "select sentto, sentfrom, boxid, id from messages";
$query = $dbh->prepare($sql);
$query->execute();
while (@row=$query->fetchrow_array()) {
  if (($row[2] == 2) or ($row[2] == 3)) {
   $row[0] = MIME::Words::decode_mimewords($row[0]);
   $friendly = &process_from($row[0]);
  } else {
   $row[1] = MIME::Words::decode_mimewords($row[1]);
   $friendly = &process_from($row[1]);
  }
  $query2->execute($row[0], $row[1], $friendly, $row[3]);
}