41 |
my @mail_to; # array to main initial message to |
my @mail_to; # array to main initial message to |
42 |
open(WHO,"who am i |") || die "who am i? $!"; |
open(WHO,"who am i |") || die "who am i? $!"; |
43 |
my $db_user=<WHO>; |
my $db_user=<WHO>; |
44 |
|
chomp $db_user; |
45 |
$db_user=~s/\s.+$//g; |
$db_user=~s/\s.+$//g; |
46 |
close(WHO); |
close(WHO); |
47 |
|
|
48 |
xdebug "koristim korinika $db_user\n"; |
xdebug "koristim korinika $db_user\n"; |
49 |
|
|
50 |
|
open(HOSTNAME,"hostname |") || die "hostname: $!"; |
51 |
|
my $hostname=<HOSTNAME>; |
52 |
|
chomp $hostname; |
53 |
|
close(HOSTNAME); |
54 |
|
|
55 |
|
xdebug "koristim hostname $hostname\n"; |
56 |
|
|
57 |
v "/etc/aliases\n"; |
v "/etc/aliases\n"; |
58 |
open(ALIAS,"/etc/aliases") || die "Can't open /etc/aliases: $!"; |
open(ALIAS,"/etc/aliases") || die "Can't open /etc/aliases: $!"; |
112 |
my $max_osoba_id=0; |
my $max_osoba_id=0; |
113 |
|
|
114 |
my $dbh = DBI->connect("DBI:Pg:dbname=informatika;host=support.pliva.hr;user=$db_user","","") || die $DBI::errstr; |
my $dbh = DBI->connect("DBI:Pg:dbname=informatika;host=support.pliva.hr;user=$db_user","","") || die $DBI::errstr; |
115 |
my $sth = $dbh->prepare("select max(id) from last_open") || die $dbh->errstr(); |
|
116 |
|
my $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr(); |
117 |
|
$sth->execute() || die $sth->errstr(); |
118 |
|
my ($ko_id)=$sth->fetchrow_array; |
119 |
|
|
120 |
|
xdebug "upotrebljavam ID kontakt osobe: $ko_id\n"; |
121 |
|
|
122 |
|
$sth = $dbh->prepare("select max(id) from last_open") || die $dbh->errstr(); |
123 |
$sth->execute() || die $sth->errstr(); |
$sth->execute() || die $sth->errstr(); |
124 |
my ($last_open)=$sth->fetchrow_array; |
my ($last_open)=$sth->fetchrow_array; |
125 |
|
|
126 |
if (! defined($open_only_id)) { |
if (! defined($open_only_id)) { |
127 |
$sth = $dbh->prepare("select id,ime,prezime,sifra,objekt,kat,soba,shell from view_otvori_nove where id > $last_open") || die $dbh->errstr(); |
$sth = $dbh->prepare("select id,ime,prezime,sifra,objekt,kat,soba,shell from view_otvori_nove where id > $last_open") || die $dbh->errstr(); |
128 |
} else { |
} else { |
152 |
$ime=nuke_chars($ime); |
$ime=nuke_chars($ime); |
153 |
$prezime=nuke_chars($prezime); |
$prezime=nuke_chars($prezime); |
154 |
|
|
155 |
my $prezime_za_login,$ime_za_login; |
my ($prezime_za_login,$ime_za_login); |
156 |
|
|
157 |
if ($prezime =~ /[- ]/) { # dva prezimena prezime1-prezime2 |
if ($prezime =~ /[- ]/) { # dva prezimena prezime1-prezime2 |
158 |
($prezime_za_login,undef) = split(/[- ]/,$prezime,2); |
($prezime_za_login,undef) = split(/[- ]/,$prezime,2); |
218 |
$full_name=~s/ +:/:/g; |
$full_name=~s/ +:/:/g; |
219 |
$full_name=~s/ +/ /g; |
$full_name=~s/ +/ /g; |
220 |
$full_name=nuke_chars($full_name); |
$full_name=nuke_chars($full_name); |
221 |
if ($shell eq "t") { |
if ($shell) { |
222 |
$shell="/usr/local/bin/bash"; |
$shell="/usr/local/bin/bash"; |
223 |
} else { |
} else { |
224 |
$shell="/usr/bin/false"; |
$shell="/usr/bin/false"; |
252 |
system "mkdir -p $dir ; mkdir $dir/bin ; \ |
system "mkdir -p $dir ; mkdir $dir/bin ; \ |
253 |
chown -R $uid:$group_id{$group} $dir ; chmod 755 $dir" if (! $debug); |
chown -R $uid:$group_id{$group} $dir ; chmod 755 $dir" if (! $debug); |
254 |
|
|
255 |
$dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($osoba_id,3,'now'::datetime,3)") if (! $debug); |
$dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($osoba_id,$ko_id,'now'::datetime,3)") if (! $debug); |
256 |
|
|
257 |
$max_osoba_id = $osoba_id if ($max_osoba_id < $osoba_id) ; |
$max_osoba_id = $osoba_id if ($max_osoba_id < $osoba_id) ; |
258 |
} |
} |
262 |
close(NPASSWD); |
close(NPASSWD); |
263 |
close(NALIAS); |
close(NALIAS); |
264 |
|
|
265 |
undef $sth; |
undef $sth,$sth2; |
266 |
$dbh->disconnect; |
$dbh->disconnect; |
267 |
|
|
268 |
system "mv /etc/passwd passwd.orig" if (! $debug); |
system "mv /etc/passwd passwd.orig" if (! $debug); |