Avatar billede kane Juniormester
15. oktober 2003 - 14:17 Der er 13 kommentarer og
1 løsning

ændring af fil.pl i dreamweaver

Kan man ikke ændre en lille ting i en .pl fil i dreamweaver uden den går i stykker? jeg har ændret en email adresse og smidt den op, og bum, så kokser det totalt.
Avatar billede mfalck Praktikant
15. oktober 2003 - 14:30 #1
det har nok noget at gøre med at den konverterer den til dos (CR/LF) og fra unix format (CR). Prøv at lægge den op som ascii og se om det ikke hjælper ?
Avatar billede mfalck Praktikant
15. oktober 2003 - 14:31 #2
du kan evt køre
perl -w <navn.pl> og se om der er mere hjælp at hente

forhåbenligt har du husket \@ i email-adressen ?!?!
Avatar billede kane Juniormester
15. oktober 2003 - 14:33 #3
ja det har jeg, hvilken program kan jeg gemme den som ascii?
Avatar billede mfalck Praktikant
15. oktober 2003 - 14:47 #4
hvis du bruger ftp så kan du overføre den som ascii - ellers er der på de fleste linux-maskiner et program som hedder dos2unix (bemærk at det sætter rettighederne på filen til rw så du skal huske at lave en chmod 755 på filen bagefter).
Avatar billede kane Juniormester
16. oktober 2003 - 08:06 #5
nu har jeg skrevet dos2unix bestil.pl men den fucker stadigvæk.

hvordan i hulen kan den drille sådan bare ved en lille email ændring.

# perl -w bestil.pl
Unrecognized escape \d passed through at Settings.pm line 25.
Unrecognized escape \w passed through at Settings.pm line 25.
String found where operator expected at bestil.pl line 137, near "my $domain          = $cgi->param(""
  (Might be a runaway multi-line "" string starting on line 136)
        (Missing semicolon on previous line?)
Bareword found where operator expected at bestil.pl line 137, near "my $domain        = $cgi->param("domain"
        (Do you need to predeclare my?)
String found where operator expected at bestil.pl line 146, near "$tpl->parse(MAIN              => ""
  (Might be a runaway multi-line "" string starting on line 137)
        (Missing semicolon on previous line?)
Bareword found where operator expected at bestil.pl line 146, near "$tpl->parse(MAIN            => "domainnoexists"
        (Missing operator before domainnoexists?)
String found where operator expected at bestil.pl line 150, near "$tpl->parse(MAIN              => ""
  (Might be a runaway multi-line "" string starting on line 146)
        (Missing semicolon on previous line?)
Bareword found where operator expected at bestil.pl line 150, near "$tpl->parse(MAIN            => "domainexists"
        (Missing operator before domainexists?)
String found where operator expected at bestil.pl line 158, near "$tpl->parse(MAIN              => ""
  (Might be a runaway multi-line "" string starting on line 150)
        (Missing semicolon on previous line?)
Bareword found where operator expected at bestil.pl line 158, near "$tpl->parse(MAIN            => "domainnoexists"
syntax error at bestil.pl line 137, near "my $domain          = $cgi->param(""
Global symbol "$domain" requires explicit package name at bestil.pl line 136.
Global symbol "$tmp" requires explicit package name at bestil.pl line 137.
Global symbol "$domain" requires explicit package name at bestil.pl line 137.
Global symbol "$tmp" requires explicit package name at bestil.pl line 137.
Global symbol "$domain" requires explicit package name at bestil.pl line 137.
Global symbol "$domain" requires explicit package name at bestil.pl line 137.
Global symbol "$tmp" requires explicit package name at bestil.pl line 137.
Global symbol "$domain" requires explicit package name at bestil.pl line 150.
Global symbol "$tmp" requires explicit package name at bestil.pl line 150.
bestil.pl has too many errors.
Avatar billede mfalck Praktikant
16. oktober 2003 - 08:23 #6
prøv evt at smide hele programmet her ...
Avatar billede kane Juniormester
16. oktober 2003 - 09:42 #7
#!/usr/bin/perl
use strict;
use lib '.';
use CGI;
use DB;
use CGI::FastTemplate;
use Settings;

my $tpl        = new CGI::FastTemplate('../tpl/bestil/');
my $cgi        = new CGI;
my $dbh        = DB::connectMySQL;
my $settings    = 0;
$tpl->no_strict;
$tpl->define(main        => 'main.html'                        ,
        onehotel        => 'onehotel.html'                    ,
        step2        => 'step2.html'                        ,
        step3        => 'step3.html'                        ,
        step4        => 'step4.html'                        ,
        step5        => 'step5.html'                        ,
        step5vat        => 'step5vat.html'                    ,
        spacer        => 'spacer.html'                    ,
        onefeature        => 'onefeature.html'                    ,
        feature0        => 'feature0.html'                    ,
        feature1        => 'feature1.html'                    ,
        feature2        => 'feature2.html'                    ,
        sfeature0        => 'sfeature0.html'                    ,
        sfeature1        => 'sfeature1.html'                    ,
        hidden        => 'hidden.html'                    ,
        page        => 'index.html'                        ,
        onenews        => 'onenews.html'                    ,
        left        => 'left.html'                        ,
       
        main2        => 'main2.html'                        ,
        featureitems    => 'featureitems.html'                    ,
        hotelitems        => 'hotelitems.html'                    ,
        featureitem    => 'featureitem.html'                    ,
        featuredesc    => 'featuredesc.html'                    ,
        featureemptyitem    => 'featureemptyitem.html'                ,
        onlycube        => 'onlycube.html'                    ,
       
        onedomain        => "onedomain.html"                    ,
       
        paysite        => 'paysite.html'                    ,
        noacceptpay    => 'noacceptpay.html'                    ,
        acceptpay        => 'acceptpay.html'                    ,
        giropay        => 'giropay.html'                    ,
       
        cvrerror1        => 'cvrerror1.html'                    ,
        cvrerror2        => 'cvrerror2.html'                    ,
       
        domainexists    => 'domainexists.html'                    ,
        domainnoexists    => 'domainnoexists.html'                );

my $do        = $cgi->param("do");
my $langcode =  $cgi->param("langcode")|| $cgi->cookie("langcode");
my ($deci,$tusind,$vat,$mont)=();
unless ($langcode)
{
    $ENV{SERVER_NAME} =~ /\.([a-zA-Z0-9]*)\Z/isg;
    my $urlname = lc($1);
    my $sth = $dbh->prepare("SELECT id,deci,tusind,vat,mont FROM landkode WHERE urlnavn = UCASE(?)");
    $sth->execute($urlname);
    ($langcode, $deci,$tusind,$vat,$mont) = $sth->fetchrow;
    $sth->finish;
}#unless
else
{
    my $urlname = lc($1);
    my $sth = $dbh->prepare("SELECT id,deci,tusind,vat,mont FROM landkode WHERE id=?");
    $sth->execute($langcode);
    ($langcode, $deci,$tusind,$vat,$mont) = $sth->fetchrow;
    $sth->finish;
}
$langcode ||= 45;
#              -domain    => '.cubehosting.dk'                    ,
my $cookie = $cgi->cookie(-name        => "langcode"                    ,
                          -value    => $langcode                    ,
                          -expires    => "+3y"                    );
$tpl->assign("LANGCODE$langcode"    => 'SELECTED'                    );

$tpl->assign(LANG_MONT            => $mont                    );
$tpl->assign(LANG_VAT            => $vat                        );


#$ENV{SERVER_NAME} =~ /\.([a-zA-Z0-9]*)\Z/isg;
#my $urlname     = lc($1);


my $sth = $dbh->prepare("SELECT        w.placeholder, wl.tekst
                        FROM        word w, word_lang wl
                        WHERE        wl.word_id    = w.id
              AND        wl.landkode_id    = ?"                );
$sth->execute($langcode);
while (my ($place, $text) = $sth->fetchrow)
{
  $tpl->assign(uc("WORD$place")    => $text                    );
}#while
$sth->finish;

if    ($do eq "step2")        {        &step2                }
elsif    ($do eq "step3")        {        &step3                }
elsif    ($do eq "step4")        {        &step4                }
elsif    ($do eq "step5")        {        &step5                }
elsif    ($do eq "step6")        {        &step6                }
elsif    ($do eq "step7")        {        &step7                }
elsif    ($do eq "test")            {        &test                }
else                    {        &main2                }
$dbh->disconnect;
exit;
sub left
{
    my $sth = $dbh->prepare("SELECT    n.id, nl.header, nl.body,
                    DATE_FORMAT(n.dato, '%e/%c/%y')
                            FROM    news n, news_lang nl
                            WHERE    n.status    = 1
                              AND    nl.news_id    = n.id
                  AND    nl.landkode_id    = ?
                            ORDER BY    n.dato DESC, nl.header
                LIMIT    10"                        );
    $sth->execute($langcode);
    $tpl->clear('NEWS');
    while (my ($id, $header, $body, $dato) = $sth->fetchrow)
    {
        $tpl->assign(ID        => $id                            ,
                    HEADER    => $header                        ,
                    BODY    => $body                        ,
            DATE    => $dato                        );
      $tpl->parse(NEWS        => ".onenews"                        );
    }#while
    $tpl->parse(LEFT            => "left"                        );
}#sub left
                                                                                                             

sub test
{
    d"ft;
    my $domain          = $cgi->param("domain");
    my $tmp        = `whois $domain`;
    chomp ($tmp);
    $tpl->assign(DOMAIN        => $domain                        );
    #FIX BY QDK
    if ($domain =~ /\.dk$/i)
    {
    if ($tmp =~ /No entries found/i)
        {
        $tpl->parse(MAIN        => "domainnoexists"                );
        }#if
    else
    {
        $tpl->parse(MAIN        => "domainexists"                );
    }#else
    }#if
    #FIX BY QDK
    elsif ($domain =~ /\.se$/i)
    {
    if ($tmp =~/No data found/i)
        {
        $tpl->parse(MAIN        => "domainnoexists"                );
        }#if
    else
    {
        $tpl->parse(MAIN        => "domainexists"                );
    }#else
    }#if
    #FIX BY QDK
    elsif ($tmp =~ /No match/isg || $tmp =~/NOT\ FOUND/isg)
    {
        $tpl->parse(MAIN        => "domainnoexists"                );
    }#elsif
    else
    {
    $tpl->parse(MAIN    => "domainexists"                    );
    }#else
#    $tpl->parse(MAIN        => "main"                        );
    $tpl->parse(PAGE        => "page"                        );
    print $cgi->header(-type    => "text/html", -cookie        => $cookie          );
    $tpl->print;
}#sub test
                                                                                                             
sub main
{
    d"ft;
    my $sth = $dbh->prepare('SELECT    h.id, l.navn, l.beskrivelse
                FROM    hoteltype h, hoteltype_lang l, landkode lk
                WHERE    h.id        = l.hoteltype_id
                  AND    l.landkode_id    = ?
                  AND    h.aktiv        = 1'                );

    $sth->execute($langcode);

    while (my ($id, $navn, $beskrivelse) = $sth->fetchrow)
    {
        $tpl->assign(ID        => $id                        ,
            NAME    => $navn                    ,
            DESC    => $beskrivelse                    );
    $tpl->parse(HOTELS    => ".onehotel"                    );
    }#while
    $tpl->parse(MAIN        => "main"                    );
    $tpl->parse(PAGE        => "page"                    );
    print $cgi->header(-type    => "text/html", -cookie        => $cookie                      );
    $tpl->print;
#    foreach my $e (keys %ENV)    {    print $e." = ".$ENV{$e}."<BR>\n"    }
}#sub main

sub main2
{
    d"ft;
    my $sth = $dbh->prepare('SELECT    h.id, l.navn, l.beskrivelse, l.opretpris
                FROM    hoteltype h, hoteltype_lang l
                WHERE    h.id        = l.hoteltype_id
                  AND    h.aktiv        = 1
                  AND    l.landkode_id    = ?
                ORDER BY    l.navn'                    );

    $sth->execute($langcode);
    my @hotels;
   
    while (my ($id, $navn, $beskrivelse, $pris) = $sth->fetchrow)
    {
    my @t = ($id, $navn, $beskrivelse, 0, $pris, '');
    push(@hotels, \@t);

    $tpl->assign(ID                => $id                ,
            NAME            => $navn            ,
            DESC            => $beskrivelse            ,
            LINK            => 'hotelid='.$id.'&do=step2'    );
    $tpl->parse(HOTELS            => '.hotelitems'        );
    }#while
    $sth->finish;
   
    my $s = $dbh->prepare('SELECT    f.id, l.navn, l.beskrivelse, l.enhedsnavn,
                    l.prispolitik, l.opretpris, f.gruppe_id
              FROM        featuretype f, featuretype_lang l,
                    gruppe g
              WHERE        f.id        = l.featuretype_id
                AND        l.landkode_id    = ?
                AND        g.id        = f.gruppe_id
              ORDER BY    g.placement,f.gruppe_id, l.navn'    );
    $s->execute($langcode);
    my $oldgruppe=0;
    my $tt=0;
    while (my ($id, $navn, $desc, $unit, $pris, $opret, $gruppe) = $s->fetchrow)
    {
    $tpl->assign(COLOR            => $tt++ % 2 ? '#4465AE':'BLACK');
    if ($oldgruppe ne $gruppe && $oldgruppe ne '0')
    {
        "line(@hotels);
    }#if
    $oldgruppe = $gruppe;
   
    $tpl->assign(NAVN            => $navn            ,
            DESC            => $desc            );
    $tpl->parse(FEATUREDESC            => '.featuredesc'        );
   
   
    my $hf = $dbh->prepare('SELECT    hf.min, hf.def, hf.max, hf.hoteltype_id
            FROM        hoteltype_featuretype hf,
                    hoteltype_lang l, hoteltype h
            WHERE        hf.featuretype_id    = ?
              AND         l.hoteltype_id    = hf.hoteltype_id
              AND        h.id        = l.hoteltype_id
              AND        h.aktiv        = 1
              AND        l.landkode_id    = ?
            ORDER BY    l.navn'                    );
    $hf->execute($id, $langcode);
    my $counter = 0;
    while (my ($min,$def,$max,$hid) = $hf->fetchrow)
    {     
        while($hotels[$counter]->[0] ne $hid)
        {
            $tpl->parse(FEATUREITEM    => '.featureemptyitem'            );
        $counter++;
        }#while
        if ($hotels[$counter]->[0] == $hid)
        {
        $hotels[$counter]->[5] = $hotels[$counter]->[5] . $id.'%3D'.($def||1).'%3B';
            $tpl->assign(MIN        => $min                ,
                DEF        => ($def ? $def: 'Ja')." $unit"    ,
                MAX        => $max                );
            $tpl->parse(FEATUREITEM        => '.featureitem'        );
        $hotels[$counter]->[3];
        my $t = $pris;
        $def ||= 1;
        $t =~ s/V/$def/sg;
        $t =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
        eval('$hotels[$counter]->[3] = $hotels[$counter]->[3] + (('.$t.'));');
        $t = $opret;
        $def ||= 1;
        $t =~ s/V/$def/sg;
        $t =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
        eval('$hotels[$counter]->[4] = $hotels[$counter]->[4] + (('.$t.'));');
        $counter++;
        }#if
    }#while
    while($counter < @hotels)
        {
            $tpl->parse(FEATUREITEM        => '.featureemptyitem'        );
        $counter++;
    }#while
   
        $hf->finish;
    $tpl->assign(NAVN            => $navn            );
    $tpl->parse(FEATURES            => '.featureitems'        );
    $tpl->clear('FEATUREITEM');
    }#while
    $sth->finish;

    $tpl->assign(COLOR            => $tt++ % 2 ? '#4465AE':'BLACK'    );

    "line(@hotels);

    foreach my $pris (@hotels)
    {
        $tpl->assign(DEF            => '<SCRIPT>document.writeln(tovaluta('.$pris->[4].',",",".") + " '.$mont.'");</SCRIPT>');
    $tpl->parse(FEATUREITEM            => '.featureitem'        );
    }

    $tpl->assign(NAVN                          => 'Oprettelsespris'    );
    $tpl->parse(FEATURES                        => '.featureitems'        );
    $tpl->clear('FEATUREITEM');

    $tpl->assign(COLOR            => $tt++ % 2 ? '#4465AE':'BLACK'    );
   
    foreach my $pris (@hotels)
    {
        $tpl->assign(DEF            => '<SCRIPT>document.writeln("<B><FONT size=2>" + tovaluta('.$pris->[3].',",",".") + " '.$mont.'</FONT></B>");</SCRIPT>');
    $tpl->parse(FEATUREITEM            => '.featureitem'        );
    }

    $tpl->assign(NAVN                => '<B>Pris pr. måned</B>'    );
    $tpl->parse(FEATURES            => '.featureitems'        );
    $tpl->clear('FEATUREITEM');
   
    "line(@hotels);
   
    foreach my $t (@hotels)
    {
    my $vattotal = (($t->[3] *12) + $t->[4])*(100+$vat)/100;
    $tpl->assign(NAME            => 'Bestil'            ,
            LINK            => 'hotelid='.$t->[0].'&do=step3("der='.$t->[5].'&vattotal='.$vattotal    );
    $tpl->parse(FEATUREITEM            => '.hotelitems'        );
    }#while
    $tpl->assign(NAVN                => ' '            );
    $tpl->parse(FEATURES            => '.featureitems'        );
    $tpl->clear('FEATUREITEM');


    "line(@hotels);
#?hotelid=$ID&do=step2;   
    my $noofhotels    = @hotels;

    $tpl->assign(COLOR                => $tt++ % 2 ? '#4465AE':'BLACK'    );
    $tpl->assign(COLSPAN            => $noofhotels            );
    $tpl->parse(FEATURES            => '.onlycube'            );
    $tpl->clear('FEATUREITEM');

    "line(@hotels);

    foreach my $t (@hotels)
    {
    $tpl->assign(ID                => $t->[0]            ,
            NAME            => 'Konfigurer'            ,
            LINK            => 'do=step2&hotelid='.$t->[0]    );
    $tpl->parse(FEATUREITEM            => '.hotelitems'        );
    }#while
    $tpl->assign(NAVN                => ' '            );
    $tpl->parse(FEATURES            => '.featureitems'        );
    $tpl->clear('FEATUREITEM');
   

   
    $tpl->parse(MAIN        => "main2"                    );
    $tpl->parse(PAGE        => "page"                    );
    print $cgi->header(-type    => "text/html", -cookie        => $cookie    );
    $tpl->print;
}#sub main2

sub emptyline
{
   
    foreach my $t (@_)
    {
        $tpl->assign(DEF            => ' '            );
    $tpl->parse(FEATUREITEM            => '.featureitem'        );
    }
    $tpl->assign(NAVN                => ' '            );
    $tpl->parse(FEATURES            => '.featureitems'        );
    $tpl->clear('FEATUREITEM');
}
sub step2
{
    d"ft;
    my $hotelid = $cgi->param('hotelid');
   
    my $sth = $dbh->prepare('SELECT     h.beskrivelse, lk.mont, lk.tusind,
                    lk.deci, lk.vat, h.opretpris, h.opretrabat, h.mdrabat
                FROM     hoteltype_lang h, landkode lk
                WHERE    h.landkode_id     = ?
                  AND    lk.id        = h.landkode_id
                  AND     h.hoteltype_id     = ?'            );
    $sth->execute($langcode, $hotelid);
    my ($desc, $mont, $tusind, $deci, $vat, $opret,$opretrabat, $mdrabat) = $sth->fetchrow;
    $sth->finish;
   

    $sth = $dbh->prepare('SELECT    f.id, hf.min, hf.max, hf.def, l.navn,
                    l.beskrivelse, l.help, l.prispolitik,
                    l.enhedsnavn, hf.spacer, l.opretpris
                      FROM    featuretype f, featuretype_lang l,
                        hoteltype_featuretype hf
                  WHERE    hf.hoteltype_id    = ?
                    AND    f.id        = hf.featuretype_id
                AND     l.featuretype_id= f.id
                    AND    l.landkode_id    = ?
                  ORDER BY    hf.placement'                );

    $sth->execute($hotelid, $langcode);
    my $no=0;
    while (my ($id, $min, $max, $def, $navn, $beskrivelse,
              $help, $prispolitik, $enhedsnavn, $spacer,
          $opretpris) = $sth->fetchrow                    )
    {
    $tpl->assign(ID            => $id                    ,
            NAME        => $navn                ,
            MIN        => $min                    ,
            MAX        => $max                    ,
            VALUE        => $def                    ,
            HELP        => $help                ,
            PRICE        => $prispolitik                ,
            ENHEDSNAVN        => $enhedsnavn                ,
            DESC        => $beskrivelse                ,
            NO            => $no                    ,
            OPRET        => $opretpris                );
    $tpl->parse(FEATURES        => (($min + $max) == 0)    ? ".feature0"    :
                      ($min == $max)    ? ".feature1"    :
                                      ".feature2"    );
    $tpl->parse(FEATURES        => ".spacer") if $spacer;
    $no++;
    }#while
    $tpl->assign(HOTELID        => $hotelid                ,
        MONT            => $mont                ,
        TUSIND            => $tusind                ,
        DECI            => $deci                ,
        VAT            => $vat                    ,
        DESC            => $desc                ,
        OPRET            => $opret                ,
        OPRETRABAT        => $opretrabat                ,
        MDRABATSTR        => ($mdrabat?" $mdrabat\% rabat" :"")                ,
        OPRETRABATSTR        => ($opretrabat ? " $opretrabat\% rabat" :"")                ,
        MDRABAT        => $mdrabat                );
    $tpl->parse(MAIN            => "step2"                );
    $tpl->parse(PAGE            => "page"                );
    print $cgi->header(-type    => "text/html", -cookie => $cookie        );
    $tpl->print;
}#sub showhotel

sub step3
{
    d"ft;
    my $hotelid     = $cgi->param('hotelid');
    my $order          = $cgi->param('order');

    $settings        ||= new Settings(cgi => $cgi, dbh => $dbh, tpl => $tpl, langcode => $langcode);
    my $extra        = 0;
   

    $tpl->assign(HOTELID        => $hotelid                ,
        ORDER            => $order                 ,
        VATTOTAL        => $cgi->param('vattotal')        ,
        VAT            => $cgi->param('vat')            );
   

#    foreach my $t (split(/;/, $order))
#    {
#    my ($key, $value)    = split(/=/, $t);
#
#    my $s = $settings->get(id => $key);
#    }#foreach
    my $value=1;
    my $s = $settings->get(id => 20);
    $extra += $s->extra(tplfield => 'EXTRA', data => $value, langcode => $langcode) if ($s != 0);

    if($extra)
    {

    $tpl->parse(MAIN        => "step3"                );
    $tpl->parse(PAGE        => "page"                );
    print $cgi->header(-type    => "text/html", -cookie => $cookie        );
    $tpl->print;
    }#if
    else
    {
    &step4;
    }#else
}#sub step3

sub step4
{
    d"ft;
    foreach my $name ($cgi->all_parameters)
    {
    next if $name eq "do";
    next if $name eq 'name';
    next if $name eq 'att';
    next if $name eq 'adress';
    next if $name eq 'zip';
    next if $name eq 'city';
    next if $name eq 'land';
    next if $name eq 'iso';
    next if $name eq 'cvr';
    next if $name eq 'email';
    next if $name eq 'tlf';
    next if $name eq 'fax';
    next if $name eq 'fakname';
    next if $name eq 'fakatt';
    next if $name eq 'fakadress';
    next if $name eq 'fakzip';
    next if $name eq 'fakcity';
    next if $name eq 'fakland';
    next if $name eq 'fakiso';
    next if $name eq 'fakcvr';
    next if $name eq 'fakemail';
    next if $name eq 'faktlf';
    next if $name eq 'fakfax';
    next if $name eq 'checkterms';
    next if $name eq 'hotelid';
    foreach my $value ($cgi->param($name))
    {
        $tpl->assign(NAME        => $name                ,
            VALUE        => $value                );
        $tpl->parse(FIELDS        => ".hidden"                );
    }#foreach
    }#foreach
    my $hotelid     = $cgi->param('hotelid');
    my $order          = $cgi->param('order');

    $settings        ||= new Settings(cgi => $cgi, dbh => $dbh, tpl => $tpl, langcode => $langcode);
    my $extra        = 0;
    my $s    =  $settings->get(id    => 20);
    $extra    += $s->extra(tplfield    => 'EXTRA', data => 1, langcode => $langcode) if ($s != 0    );
    $s->parseDomainArray('DOMAINSURLS');
   
    $tpl->assign(HOTELID    => $cgi->param('hotelid')            );
    $tpl->assign(NAME        => $cgi->param('name')                );
    $tpl->assign(ATT        => $cgi->param('att')                );
    $tpl->assign(ADRESS        => $cgi->param('adress')            );
    $tpl->assign(ZIP        => $cgi->param('zip')                );
    $tpl->assign(CITY        => $cgi->param('city')                );
    $tpl->assign("LAND".$cgi->param('land')=>'SELECTED'                );
    $tpl->assign(CVR        => $cgi->param('cvr')                );
    $tpl->assign(ISO        => $cgi->param('iso')                );
    $tpl->assign(EMAIL        => $cgi->param('email')                );
    $tpl->assign(TLF        => $cgi->param('tlf')                );
    $tpl->assign(FAX        => $cgi->param('fax')                );
    $tpl->assign(FAKNAME    => $cgi->param('fakname')            );
    $tpl->assign(FAKATT        => $cgi->param('fakatt')            );
    $tpl->assign(FAKADRESS    => $cgi->param('fakadress')            );
    $tpl->assign(FAKZIP        => $cgi->param('fakzip')            );
    $tpl->assign(FAKCITY    => $cgi->param('fakcity')            );
    $tpl->assign("FAKLAND".$cgi->param('fakland')=>'SELECTED'            );
    $tpl->assign(FAKCVR        => $cgi->param('fakcvr')            );
    $tpl->assign(FAKISO        => $cgi->param('fakiso')            );
    $tpl->assign(FAKEMAIL    => $cgi->param('fakemail')            );
    $tpl->assign(FAKTLF        => $cgi->param('faktlf')            );
    $tpl->assign(FAKFAX        => $cgi->param('fakfax')            );

    $tpl->parse(MAIN            => "step4"                );
    $tpl->parse(PAGE            => "page"                );
    print $cgi->header(-type    => "text/html", -cookie    => $cookie        );
    $tpl->print;
}#step4
sub step5
{
    my $iso         = $cgi->param('iso');
    my $cvr         = $cgi->param('cvr');
    my $fakiso        = $cgi->param('fakiso');
    my $fakcvr        = $cgi->param('fakcvr');
    my $cvrcheck     = `lynx -dump "http://europa.eu.int/comm/taxation_customs/vies/cgi-bin/viesquer?Lang=DA&MS=$iso&VAT=$cvr"`;
    my $fakcvrcheck    = `lynx -dump "http://europa.eu.int/comm/taxation_customs/vies/cgi-bin/viesquer?Lang=DA&MS=$fakiso&VAT=$fakcvr"`;
    if ($cvr && 1 == 0)
    {
    if ($cvrcheck =~ /Nej, ugyldigt momregistreringsnummer/isg)
    {
            $tpl->parse(ERROR => 'cvrerror1');
        &step4(1);
        return;
    }#if
    else
    {
        unless ($cvrcheck =~/ja, gyldigt momsregistreringsnummer/isg)
        {
            $tpl->parse(ERROR => 'cvrerror2');
            &step4(2);
        system("echo \"to: mail\@domain.dk\nfrom: support\@domain.dk\nsubject: CVR check fejl\n\nCVR NR : $iso-$cvr\n\nSvar\n\n$cvrcheck\" | /var/qmail/bin/qmail-inject");
            return;
        }#unless
    }#else
    }#if
    if ($fakcvr && 1 == 0)
    {
    if ($fakcvrcheck =~ /Nej, ugyldigt momregistreringsnummer/isg)
    {
            $tpl->parse(FAKERROR => 'cvrerror1');
        &step4(1);
        return;
    }#if
    else
    {
        unless ($fakcvrcheck =~/ja, gyldigt momsregistreringsnummer/isg)
        {
            $tpl->parse(FAKERROR => 'cvrerror2');
            &step4(2);
        system("echo \"to: mail\@domain.dk\nfrom: support\@domain.dk\nsubject: CVR check fejl\n\nCVR NR : $fakiso-$fakcvr\n\nSvar\n\n$fakcvrcheck\" | /var/qmail/bin/qmail-inject");
            return;
        }#unless
    }#else
    }#if

    d"ft;

    print $cgi->header(-type    => "text/html", -cookie    => $cookie        );
   
    my $hotelid     = $cgi->param('hotelid');

    my $name        = $cgi->param('name');
    my $att        = $cgi->param('att');
    my $adress        = $cgi->param('adress');
    my $zip        = $cgi->param('zip');
    my $city        = $cgi->param('city');
    my $land        = $cgi->param('land');
    my $iso        = $cgi->param('iso');
    my $cvr        = $cgi->param('cvr');
    my $email        = $cgi->param('email');
    my $tlf        = $cgi->param('tlf');
    my $fax        = $cgi->param('fax');
    my $fakname        = $cgi->param('fakname');
    my $fakatt        = $cgi->param('fakatt');
    my $fakadress    = $cgi->param('fakadress');
    my $fakzip        = $cgi->param('fakzip');
    my $fakcity        = $cgi->param('fakcity');
    my $fakland        = $cgi->param('fakland');
    my $fakiso        = $cgi->param('fakiso');
    my $fakcvr        = $cgi->param('fakcvr');
    my $fakemail    = $cgi->param('fakemail');
    my $faktlf        = $cgi->param('faktlf');
    my $fakfax        = $cgi->param('fakfax');

    my $order        = $cgi->param('order');
   
    my %orders;
    my %corders;

    return unless $cgi->param('domainlist');

    foreach my $t (split(/;/, $order))
    {
    my ($key, $value)    = split(/=/, $t);
    $orders{$key}        = $value;
    }#foreach
   
    my $sth = $dbh->prepare("SELECT    f.id, hf.min, hf.max, l.navn,
                    l.prispolitik,l.opretpris,l.enhedsnavn
                    FROM    featuretype f, featuretype_lang l,
                        hoteltype_featuretype hf
                WHERE    hf.hoteltype_id    = ?
                  AND    f.id        = hf.featuretype_id
                  AND     l.featuretype_id= f.id
                  AND    l.landkode_id    = ?"            );
    $sth->execute($hotelid, $langcode);
    my $error = 0;

    while (my ($id, $min, $max, $navn, $prispolitik, $opret, $enhed) = $sth->fetchrow)
    {
    next unless exists($orders{$id});
    if (exists($orders{$id})
    && ((($orders{$id} < $min) || ($orders{$id} > $max))
    && ($min+$max == 0 && $orders{$id}>1))                    )
    {
        return;
    }#if
    else
    {
       
        $corders{$id} = $orders{$id}.";$prispolitik;$opret;$enhed;$max;$navn";

    }#else
    }#while
   
    $settings        ||= new Settings(cgi => $cgi, dbh => $dbh, tpl => $tpl);

    my $total=0;
    my $totalopret=0;
    foreach my $id (keys %corders)
    {
    $corders{$id} =~ /(\d+);(.*?);(.*?);(.*?);(.*?);(.+)/;
    my ($antal, $prispolitik, $opret, $enhed, $max, $navn) = ($1, $2, $3, $4, $5, $6);
    my $pris = 0;
    $prispolitik     =~ s/V/$antal/isg;
    $opret        =~ s/V/$antal/isg;
    $prispolitik =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
    $opret =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
    eval('$pris += ' .$prispolitik .";");
    eval('$totalopret += (' .$opret . ');');
    $tpl->assign(NAME        => $navn                ,
            NO            => ($max ? $antal : '')            ,
            EXTRA        => ' '                    ,
            ENHED        => $enhed                );
    $tpl->parse(FEATURES        => ".onefeature"            );
    $total = $total + $pris;
    }#foreach
    $sth->finish;

    my $sth = $dbh->prepare("SELECT    h.navn, h.opretpris, h.opretrabat, h.mdrabat
                FROM     hoteltype_lang h
                WHERE     h.hoteltype_id     = ?
                  AND     h.landkode_id    = ?"            );
    $sth->execute($hotelid, $langcode);
    my ($hotel, $hotelopret, $opretrabat, $mdrabat) = $sth->fetchrow;
    $sth->finish;
    my $webhotel    = ($total*12 -($total*12*$opretrabat/100))
            + ($hotelopret + $totalopret - (($hotelopret + $totalopret) * $opretrabat / 100));
    $total=0;

    my $sth = $dbh->prepare("SELECT    l.oprettelse,l.flytning
                FROM     domainname_lang l, domainname d
                WHERE     l.domainname_id    = d.id
                  AND    d.url        = ?
                  AND    l.landkode_id    = ?"        );
    my $nodom =0;
    my $web =0;
    foreach my $line (split (/\|/, $cgi->param('domainlist')))
    {
    print STDERR "->$line\n";
    my ($name, $type, $option, $hotel) = split(',', $line);
#    $name        =~ /extradomain(\d+)/;
#    $name        = $cgi->param($name);
    $name        =~ s/\Awww\.//i;
    next if $name eq '';
#    my $type    = $cgi->param('extradomaintype'        . $1);
#    my $hotel    = $cgi->param('extradomainwebhotel'    . $1);
    $hotel        = $hotel ? 0 : 1;
#    my $option    = $cgi->param('extradomainoption'    . $1);
    my($dpris)=0;
    if ($option eq '0')
    {
        $sth->execute($type, $langcode);
        next unless ($dpris)= $sth->fetchrow;
        $nodom++;
        $total = $total + $dpris;
    }
    if ($option eq '1')
    {
        $sth->execute($type, $langcode);
        my $flyt;
        next unless ($dpris, $flyt)= $sth->fetchrow;
        $nodom++;
        $dpris =$flyt;
        $total = $total + $flyt;
    }
    $web++ if ($hotel);
   
   
    $tpl->assign(DOMAINNAME        => "$name.$type"            ,
        DOMAINPRIS        => $dpris                ,
        DOAMINTYPE        => $option eq '0' ? 'Oprettes'        :
                      $option eq '1' ? 'Flyttes'        :
                                'Brugerstyret'    ,
        DOMAINWEBHOTEL        => $hotel  eq '1' ? 'med webhotel'     :
                                'uden webhotel'    );

    $tpl->parse(DOMAINS            => ".onedomain"                );
    }#foreach


    foreach my $name ($cgi->all_parameters)
    {
    next if $name eq "do";
    foreach my $value ($cgi->param($name))
    {
        $tpl->assign(NAME        => $name                ,
            VALUE        => $value                );
        $tpl->parse(HIDDENS        => ".hidden"                );
    }#foreach
    }#foreach
    $tpl->assign(NAME            => 'do'                    ,
        VALUE            => 'step6'                );
    $tpl->parse(HIDDENS            => ".hidden"                );
   
    $tpl->assign(HOTEL            => $hotel                ,
        WEBHOTEL        => $webhotel*$web             ,
        TOTAL            => ($total+($web*$webhotel))        ,
        VATTOTAL        => (($total+($web*$webhotel))*(100+$vat)/100)    ,
        VAT            => (($total+($web*$webhotel))*$vat/100)    ,
        NOOFDOMAIN        => $web                    ,

        NAVN            => $name                ,
        ATT            => $att                    ,
        ADRESS            => $adress                ,
        POSTNO            => $zip                    ,
        CITY            => $city                ,
        LAND            => $land                ,
        CVR            => $cvr                    ,
        TLF            => $tlf                    ,
        FAX            => $fax                    ,
        EMAIL            => $email                ,
       
        FAKNAVN        => $fakname                ,
        FAKATT            => $fakatt                ,
        FAKADRESS        => $fakadress                ,
        FAKPOSTNO        => $fakzip                ,
        FAKCITY        => $fakcity                ,
        FAKLAND        => $fakland                ,
        FAKCVR            => $fakcvr                ,
        FAKTLF            => $faktlf                ,
        FAKFAX            => $fakfax                ,
        FAKEMAIL        => $fakemail                );
    if ($land eq 'DK' || $cvr eq '')       
    {
    $tpl->parse(SHOWVAT        => "step5vat"                );
    }
    $tpl->parse(MAIN            => "step5"                );
    $tpl->parse(PAGE            => "page"                );

    $tpl->print;
}

sub step6
{
    my $hotelid     = $cgi->param('hotelid');

    my $name        = $cgi->param('name');
    my $att        = $cgi->param('att');
    my $adress        = $cgi->param('adress');
    my $zip        = $cgi->param('zip');
    my $city        = $cgi->param('city');
    my $land        = $cgi->param('land');
    my $cvr        = $cgi->param('cvr');
    my $email        = $cgi->param('email');
    my $tlf        = $cgi->param('tlf');
    my $fax        = $cgi->param('fax');
    my $fakname        = $cgi->param('fakname');
    my $fakatt        = $cgi->param('fakatt');
    my $fakadress    = $cgi->param('fakadress');
    my $fakzip        = $cgi->param('fakzip');
    my $fakcity        = $cgi->param('fakcity');
    my $fakland        = $cgi->param('fakland');
    my $fakcvr        = $cgi->param('fakcvr');
    my $fakemail    = $cgi->param('fakemail');
    my $faktlf        = $cgi->param('faktlf');
    my $fakfax        = $cgi->param('fakfax');
   
    my $betal        = $cgi->param('betalingsform');

    $tlf=~s/[^+0-9]//isg;
    $fax=~s/[^+0-9]//isg;
    my $order        = $cgi->param('order');
   
    my %orders;
    my %corders;
    foreach my $t (split(/;/, $order))
    {
    my ($key, $value)    = split(/=/, $t);
    $orders{$key}        = $value;
    }#foreach

    my $sth = $dbh->prepare("SELECT    f.id, hf.min, hf.max, l.navn,
                    l.prispolitik,l.opretpris,l.enhedsnavn
                    FROM    featuretype f, featuretype_lang l,
                        hoteltype_featuretype hf
                WHERE    hf.hoteltype_id    = ?
                  AND    f.id        = hf.featuretype_id
                  AND     l.featuretype_id= f.id
                  AND    l.landkode_id    = ?"        );
    $sth->execute($hotelid, $langcode);
    my $error = 0;

    while (my ($id, $min, $max, $navn, $prispolitik, $opret, $enhed) = $sth->fetchrow)
    {
    next unless exists($orders{$id});
    if (exists($orders{$id}) && ((($orders{$id} < $min) || ($orders{$id} > $max)) && ($min+$max == 0 && $orders{$id}>1)) )
    {
        return;
    }#if
    else
    {
        $corders{$id} = "$orders{$id};$prispolitik;$opret;$enhed;$navn";
    }#else
    }#while
   
    #tester at der er et domainer
    return unless $cgi->param('domainlist');
   
    my $sth = $dbh->prepare("SELECT    opretpris,opretrabat, mdrabat
                FROM     hoteltype_lang   
                WHERE     hoteltype_id     = ?
                  AND    landkode_id    = ?"            );
    $sth->execute($hotelid, $langcode);
    my ($hotelopret,$opretrabat, $mdrabat) = $sth->fetchrow;
    $sth->finish;

    my @random = ();
    for(my $i=0; $i<30;$i++)
    {
    push(@random, 'char(((rand() * 10000) % 25) + 97)');   
    }#for
    $sth = $dbh->prepare("INSERT INTO kunde(navn, att, adresse, postnr, city,
                        land, cvr, fakland, faktlf, fakfax, fakemail,
                        landkode_id, email, faknavn,
                        fakatt, fakadresse, fakpostnr,
                        faklandkode_id, betalingsform,
                        tlf, fax, fakcvr,
                        oprettelsedato, check_id)
              VALUES (?,?,?,?,?,?,?,?,?,?,?,$langcode,?,?,?,?,?,$langcode,?,?,?,?,now(), concat(" . join(",", @random) . "))" );
    $sth->execute($name, $att, $adress,    $zip, $city, $land, $cvr, $fakland, $faktlf, $fakfax,
        $fakemail, $email, $fakname, $fakatt, $fakadress, $fakzip, $betal, $tlf, $fax, $fakcvr    );
    my $kundeid = $sth->{'mysql_insertid'};
    $sth->finish;

    $sth = $dbh->prepare("INSERT INTO bestilling(kunde_id,    hoteltype_id,    dato,        opretrabat    )
              VALUES        (?,          ?,        now(),        ?        )");
    $sth->execute($kundeid, $hotelid, $opretrabat);
    my $bestillingid = $sth->{'mysql_insertid'};
    $sth->finish;

    $sth = $dbh->prepare("INSERT INTO bestilling_featuretype (bestilling_id,
                                  featuretype_id,
                                  antal, mdpris, opretpris,
                                  status)
              VALUES (?, ?, ?, ?, ?, 0)"                    );
   
    $settings        ||= new Settings(cgi => $cgi, dbh => $dbh, tpl => $tpl);

    my $total=0;
    my $totalopret=0;
   
    foreach my $id (keys %corders)
    {
    $corders{$id} =~ /(\d+);(.*?);(.*?);(.*?);(.+)/;
    my ($antal, $prispolitik, $opret, $enhed, $navn) = ($1, $2, $3, $4, $5);
    my $pris = 0;
    $prispolitik =~ s/V/$antal/isg;
    $opret =~ s/V/$antal/isg;
    $prispolitik =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
    $opret =~ s/pow\[(.*?)\,(.*?)\]/\1\*\*\2/sg;
    eval('$pris = ' .$prispolitik .";");
    eval('$opret = ' .$opret .";");
    eval('$totalopret += (' .$opret .');');
        $sth->execute($bestillingid, $id, $antal, ($pris - ($pris *$mdrabat/100)), ($opret - ($opret * $opretrabat / 100)));
    $total = $total + $pris;
    }#foreach
    $sth->finish;

############################

#($total * 12) + $hotelopret + $totalopret;
    my $webhotel = ($total*12 -($total*12*$opretrabat/100)) + ($hotelopret + $totalopret - (($hotelopret + $totalopret) * $opretrabat / 100));
               
    $total    = 0;
    my $nodom    = 0;
    my $web    = 0;
    my $sth = $dbh->prepare("SELECT    l.oprettelse, l.flytning, d.id
                FROM     domainname_lang l, domainname d
                WHERE     l.domainname_id    = d.id
                  AND    d.url        = ?
                  AND    l.landkode_id    = ?"        );

    my $hotelopret = ($hotelopret + $totalopret - (($hotelopret + $totalopret)    * $opretrabat / 100));
    my $hotelmd      = ($total * 12         - ($total * 12             * $opretrabat / 100));

    my $dsth = $dbh->prepare("INSERT INTO bestilling_domain(bestilling_id,domainname,action,webhotel,domainname_id,pris,getfax) VALUES (?,?,?,?,?,?,?)");

#    foreach my $name (grep(/extradomain\d+/, $cgi->all_parameters))
#    {
    foreach my $line (split (/\|/, $cgi->param('domainlist')))
    {
    my ($name, $type, $option, $hotel) = split(',', $line);
#    $name         =~ /extradomain(\d+)/;
#    $name         = $cgi->param($name);
    $name        =~ s/\Awww\.//i;
    next if $name eq '';
#    my $type    = $cgi->param('extradomaintype'     . $1);
#    my $option    = $cgi->param('extradomainoption'    . $1);
#    my $hotel    = $cgi->param('extradomainwebhotel'    . $1);
    $hotel        = $hotel ? 0 :1;
    my $dpris    = 0;
    my $confirmed    = 0;
    my ($flyt, $did);
    $sth->execute($type, $langcode);
    next unless ($dpris, $flyt, $did)= $sth->fetchrow;
    if ($option eq '0')
    {
        $nodom++;
        $total = $total + $dpris;
    }
    elsif ($option eq '1')
    {
        $dpris= $flyt;
        $nodom++;
        $total = $total + $dpris;
    }
    else
    {
        $dpris=0;
    }
    $web++        if $hotel;
    $confirmed=1    if $did>1;
    $confirmed=1    if $option eq '2';

    $name = lc "$name.$type";
        $name =~s/\.+/\./isg;
        $name =~s/\A\.+//isg;
        $name =~s/\.+\Z//isg;
       
           
    $dsth->execute($bestillingid, $name, $option, $hotel, $did, $dpris, $confirmed);
    }#foreach
    $dsth->finish;
    my $sth = $dbh->prepare("UPDATE bestilling SET opret = ?, hotelopret=?, hotelmd=? WHERE id = ?");
    $sth->execute($total + ($web * $webhotel), ($hotelopret * $web), ($hotelmd * $web), $bestillingid);
    $sth->finish;

    $sth = $dbh->prepare("INSERT INTO nextpay(kunde_id,dato,amount,bestilling_id,nextyear)values(?,now(),?,?,date_add(now(), interval 1 year))");
    $sth->execute($kundeid, ($total + ($web * $webhotel)), $bestillingid);
    $sth->finish;
#############################

    if ($cgi->param('betalingsform') eq '2')
    {
    d"ft;
   
    print $cgi->header(-type    => "text/html", -cookie => $cookie    );
    $tpl->assign(NAVN        => $name                ,
            ATT        => $att                    ,
            ADRESS        => $adress                ,
            POSTNO        => $zip                    ,
            CITY        => $city                ,
            EMAIL        => $email                ,
            FAKNAVN        => $fakname                ,
            FAKATT        => $fakatt                ,
            FAKADRESS        => $fakadress                ,
            FAKPOSTNO        => $fakzip                ,
            FAKCITY        => $fakcity                ,
       
            TOTAL        => (($total+($web*$webhotel)))        ,
            VAT        => (($total+($web*$webhotel)) * $vat/100)    ,
            VATTOTAL        => (($total+($web*$webhotel)) * (100+$vat)/100),
       
            ORDERNO        => $bestillingid            );
    $tpl->parse(MAIN        => "paysite"                );
    $tpl->parse(SHOWVAT        => "step5vat"                );
        $tpl->parse(PAGE        => "page"                );
    $tpl->print;
    }#if
    else
    {
    &step7;
    }#else
}#sub step6


sub step7
{
    d"ft;
    print $cgi->header(-type    => "text/html", -cookie => $cookie        );
    if ($cgi->param('do') eq 'step7')
    {
        if($cgi->param('accept') ne '0')
    {
        $tpl->parse(MAIN        => "acceptpay"                );
        }#if
    else
    {
        $tpl->parse(MAIN        => "noacceptpay"            );
    }#else
    }#if
    else
    {
    $tpl->parse(MAIN        => "giropay"                );
    }#else
    $tpl->parse(PAGE            => "page"                );
    $tpl->print;
}
Avatar billede mfalck Praktikant
16. oktober 2003 - 09:53 #8
der er i al fald noget vrøvl i din fil: 

d"ft;
Avatar billede mfalck Praktikant
16. oktober 2003 - 09:55 #9
der er også noget i linien

"line(@hotels);
Avatar billede mfalck Praktikant
16. oktober 2003 - 10:03 #10
hmm .. jeg tror at dreamweaver har ombrudt nogle linier samt har fået lavet noget ved nogle linier (som den måske har opfattet som noget kode som den ville hjælpe med) som det ikke skulle have gjort .. jeg håber at du har den gamle fil liggende, ellers er det en større opgave at få den tilbage i stand.
Avatar billede mfalck Praktikant
16. oktober 2003 - 10:23 #11
æh undskyld at jeg sprøger, men har programmet virket nogensinde ?!! der er en del fejl i.
Avatar billede kane Juniormester
28. november 2004 - 23:17 #12
lukker
Avatar billede kane Juniormester
28. november 2004 - 23:18 #13
umm hvis du vil have point må jeg lige oprette et nyt
Så ikke du ikke havde svaret
Avatar billede mfalck Praktikant
29. november 2004 - 00:38 #14
ok - fik du det til at virke?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester