grinia
Сообщений: 1
Оценки: 0
Присоединился: 2009-09-28 20:07:40.040000
|
Скрипт: Autoresponder Unlimited 2.0 Баг 1: я имею 2 сообщения в автоответчике вывод для редактирования писем: message1 message2 но показывется: message2 message2 Кто нибудь может посмотреть эту чать кода, и подсказать в чем ошибка и как ее исправить? Я ничего не понимаю в Perl и очень прошу помощи специалиста! Файл periods.txt содержит две строки: 0 7 В веб папке лежать письма с сообщениями: letter1.txt letter2.txt Второй баг: при переходе по ссылке: http://www.my_site_name.com/cgi-bin/autoresponder/ar.cgi?mode=letters доступ в админку без пароля. Как закрыть эту дыру??? сам код: #!/usr/bin/perl require "config.cgi"; &configure; $checkuserfile=""; splice(@checkuserarray); $scripturl=$scriptpath; $mailprog=$mailprog." -i -t"; $admin=$fromaddr; @months=("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); @mdays = (31,28,31,30,31,30,31,31,30,31,30,31); require "Lite.pm"; $|=1; if ($activate){ &mailer; exit; } &readparse; if ($FORM{'mode'} eq "showpanels"){ &showpanels; } elsif ($FORM{'mode'} eq "showars"){ &showars; } elsif ($FORM{'mode'} eq "4"){ addar($FORM{'adar'}); } elsif ($FORM{'mode'} eq "5"){ &checkform; } elsif ($FORM{'mode'} eq "1"){ @arlist=getarlist(); foreach(@arlist){ if ($FORM{"$_"} ne "") { push(@todel,$FORM{"$_"}); $rrr=$FORM{"$_"}.", ".$rrr; } } # $ondelars="onload=\"javascript:parent.main.location='".$htmlpath."index.htm'\""; delar(@todel); } elsif ($FORM{'mode'} eq "letters"){ letters($FORM{'ar'}); } elsif ($FORM{'mode'} eq "newlet"){ &showpanels; letterbody("Type Your Subject Here!","Type Your Message Here!",$FORM{'newone'}); &footer; } elsif ($FORM{'mode'} eq "saveletter"){ $fname="letter$FORM{'num'}"."\.txt"; ($pattach)=getattach("$FORM{'ar'}/$fname"); $pattach=~/.*\.(.*)/; if($pattach ne $filetoattach && $filetoattach ne ""){unlink("$FORM{'ar'}/upfile$FORM{'num'}.$1");} if ($fname ne "letter.txt"){ open(LETTER,">$FORM{'ar'}/$fname"); flock(LETTER,$LOCK_EX); print LETTER "Subject:$FORM{'subject'}\n"; if($filetoattach eq ""){$filetoattach=$pattach}; print LETTER "Attachment:$filetoattach\n"; $body=$FORM{'body'}; $body=~s/\r\s/\r/g; print LETTER "$body"; close(LETTER); }; @kkeys=getfiles("$FORM{'ar'}"); @periods[0]=0; if ($FORM{'edit'} eq ""){ foreach(@kkeys){ if (/letter(\d+)/) { $per=$FORM{$_}; if ($per eq ""){ if($1==1){ $per=0; } else { $per=@periods[$1-2]+1; }; } @periods[$1-1]=$per; } }; if ($#periods!=-1){ open(PERIODS,">$FORM{'ar'}/periods.txt"); flock(PERIODS,$LOCK_EX); my($idxp); print PERIODS "0\n"; for($idxp=1;$idxp<=$#periods;$idxp++){ if ((@periods[$idxp]=~/\D+/)||(@periods[$idxp]<=@periods[$idxp-1])){@periods[$idxp]=@periods[$idxp-1]+1}; print PERIODS "@periods[$idxp]\n"; }; close(PERIODS); }; my($fromars,$namears,$unlink,$redirect,$sendad)=($FORM{'fromfield'},$FORM{'namefield'},$FORM{'unlink'},$FORM{'redirect'},$FORM{'sendad'}); if (open(FILE,">$FORM{'ar'}/$FORM{'ar'}.cfg")){ flock(FILE,$LOCK_EX); print FILE "$fromars\n$namears\n$unlink\n$redirect\n$sendad\n"; close(FILE); }; }; if ($FORM{'period'} ne "" && $FORM{'import'} ne "") { &importusers; } letters($FORM{'ar'}); } elsif ($FORM{'mode'} eq "read"){ $fname=$FORM{'fname'}; open(LETTER,"$FORM{'ar'}/$fname"); flock(LETTER,$LOCK_EX); $str=<LETTER>; $str=~/Subject:(.*)/; $subject=$1; $str=<LETTER>; $str=~/Attachment:(.*)/; $attachmentfile=$1; while(!eof(LETTER)) { $str=<LETTER>; chomp($str); $str=~s/\n//g; $body=$body.$str; }; close(LETTER); &showpanels; letterbody($subject,$body,$FORM{'num'},$attachmentfile,$getit); &footer; } elsif ($FORM{'mode'} eq "delletter"){ if ($FORM{'num'} ne ""){ $fname="letter$FORM{'num'}"."\.txt"; my($attach)=getattach("$FORM{'ar'}/$fname"); $attach=~/.*\.(.*)/; unlink("$FORM{'ar'}/$fname"); unlink("$FORM{'ar'}/upfile$FORM{'num'}.$1"); my(@files1)=(getfiles("$FORM{'ar'}")); @kkeys=sort blia @files1; chdir($FORM{'ar'}); foreach(@kkeys){ ~/letter(\d+)/; if ($1>$FORM{'num'}){ $new=$1-1; ($pattach)=getattach("letter$1.txt"); rename("letter$1.txt","letter$new.txt"); $num=$1; $pattach=~/.*\.(.*)$/; if ($pattach ne ""){ rename("upfile$num.$1","upfile$new.$1"); }; } }; chdir(".."); if(open(PER,"$FORM{'ar'}/periods.txt")){ flock(PER,$LOCK_EX); $linenum=1; while(!eof(PER)){ $line=<PER>; chomp($line); if ($linenum!=$FORM{'num'}) {push(@newone,$line)}; $linenum++; } close(PER); } if(open(PER,">$FORM{'ar'}/periods.txt")){ flock(PER,$LOCK_EX); foreach(@newone){print PER "$_\n"}; close(PER); }; letters($FORM{'ar'}); }else {error("Nothing!!!")} } elsif ($FORM{'mode'} eq "register"){ ®ister; print "</form></body>"; } elsif ($FORM{'mode'} eq "mailer"){ &mailer; error("Ales good!"); } elsif ($FORM{'mode'} eq "r"){ &unlinkuser; } elsif ($FORM{'mode'} eq "code"){ &showpanels; &generator; &footer; } elsif ($FORM{'mode'} eq "delattach"){ ($subj,$bod,$attach)=getletter("$FORM{'ar'}/letter$FORM{'num'}.txt"); $attach=~/.*\.(.*)/; unlink("$FORM{'ar'}/upfile$FORM{'num'}.$1"); open(LETTER,">$FORM{'ar'}/letter$FORM{'num'}.txt"); flock(LETTER,$LOCK_EX); print LETTER "Subject:$subj\n"; print LETTER "Attachment:\n"; print LETTER "$bod"; close(LETTER); letters($FORM{'ar'}); print "</form></body>"; } elsif ($FORM{'mode'} eq "secure"){ if($FORM{'password'} eq $password){ &showpanels; } else {&checkform}; }elsif ($FORM{'mode'} eq "export"){ &exportmails; } else { error("Unexpected error"); } sub getfiles{ my(@files1); opendir(DIR,"@_[0]") || die "Cannot open $userdir!"; while (@files=readdir(DIR)) { foreach $file(@files){ if ($file ne ".." && $file ne "." && $file ne "" && $file=~/letter\d*\.txt/) { push(@files1,$file); } }; }; return @files1; } sub getattach{ my($str); open(LETTER,"@_[0]"); flock(LETTER,$LOCK_EX); $str=<LETTER>; $str=<LETTER>; chomp($str); $str=~/Attachment:(.*)/; close(LETTER); return $1 } sub showtitle{ print "<p>AUTORESPONDER<p>\n"; } sub header { print "Content-type: text/html\n\n"; print "<!–//HEAD//–>\n"; print "<html><head>\n"; print "<title>Autoresponder Admin Control Panel</title>\n"; print "<link rel='stylesheet' href='".$htmlpath."kb_style.css'>\n"; print "<script language='javascript'>\n"; print "function model(num){\n"; print " document.left.mode.value=num;\n"; print " document.left.submit();\n"; print "}\n"; print "</script></head>\n"; # print "<body marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>\n"; print "<body>\n"; print "<!–//HEAD//–>\n"; } #header sub showpanels{ &header; print "<!–//BEGIN//–>\n"; print "<table height='100%' width='100%' cellpadding='0' cellspacing='0'>\n"; # print "<tr><td width='753' height='180' background='".$imgpath."/bg4.gif'><img src='".$imgpath."/top.jpg' width='753' height='180'></td></tr>\n"; print "<TR><td align='center'>\n"; print "<table height='100%' width='100%' cellpadding='0' cellspacing='0'>\n"; print "<tr><td valign='top' align='center' width='190'>\n"; print "<!–//BEGIN//–>\n"; &showars; } #showpannels sub footer { print "<!–//END//–>\n"; print "</TD></TR></table>\n"; print "</TD></TR></table>\n"; print "</body></html>\n"; print "<!–//END//–>\n"; }; sub showars{ print"<!–//ARS//–>\n"; print"<br><br><br><br>\n"; print"<form method='POST' action='".$scripturl."' name='left'>\n"; print"<table width='95%' cellspacing='0' cellpadding='2' border='1'>\n"; if (open(FILE,"responders.cfg")){ flock(FILE,$LOCK_EX); foreach(<FILE>){ chomp($_); print "<tr><td width='20'><input type='checkbox' name='".$_."' value='".$_."'></td><td width='100%'><p> <a href='$scripturl?mode=letters&ar=$_&password=".$FORM{'password'}."'>".$_."</a></p></td></tr>\n"; }; close(FILE); }; print"</table><br>\n"; print"<table width='80%' cellspacing='0' cellpadding='2' border='0'>\n"; print"<tr><td align='center' colspan='2'><p>Select a nickname<br>for your new account<br>(3-8 letters and digits)</p></td></tr>\n"; print"<tr><td align='center' colspan='2'><input type='text' name='adar' size='12' maxlength='8' class='edit1'></td></tr>\n"; print"<tr><td align='center' colspan='2'><input alt='Add account' type='image' src='".$imgpath."/add_account.gif' value='Add Account' name='B2' onclick='model(\"4\")' class='edit1'></td></tr>\n"; print"<tr><td align='center' colspan='2'><p>Select the account(s)<br>you want to remove and<br>click this button:</p></td></tr>\n"; print"<tr><td align='center' colspan='2'><input type='image' src='".$imgpath."/del_account.gif' value='Delete Account(s)' name='B1' onclick='model(\"1\")' class='edit1'></td></tr>\n"; print"<tr><td align='center' colspan='2'><p>Warning: All data will be lost</p></td></tr>\n"; print"<tr><td align='center' colspan='2'><input type='image' src='".$imgpath."/logout.gif' value='Logout' name='B3' onclick='model(\"5\")' class='edit1'></td></tr>\n"; print"</table>\n"; print"<input type='hidden' name=mode value=''>\n"; print"<input type='hidden' name=password value=".$FORM{'password'}.">\n"; print"<!– <br><br><br><input type='image' src='".$imgpath."/help.gif' value='Help' name='B3' onclick='model(\"2\")'> –>\n"; print"</form>\n"; print"</td><td width='32'> </td><td>\n"; print"<!–//ARS//–>\n"; } #showars sub countusers{ my($i)=0; if (open(USERSFILE,"$FORM{'ar'}/users.txt")){ flock(USERSFILE,$LOCK_EX); while(<USERSFILE>){ $i++ } flock(USERSFILE,$LOCK_UN); close(USERSFILE); } return $i; } sub letters{ my(@periods); my($fromars,$namears,$unlink,$redirect,$fromad)=(getarlist("$FORM{'ar'}/$FORM{'ar'}.cfg")); if ($unlink == 1){$unlink="checked"}; if ($fromad == 1){$fromad="checked"}; &showpanels; print "<!–//LETTERS//–>\n"; print "<p><font size='4'><b>Autoresponder: <a target='main' href='$scripturl?mode=letters&ar=@_[0]&password=$FORM{'password'}'><font color=red>@_[0]</font></b></font></a></p>\n"; print "<p><font size='2'><b>Active prospects: <font color=red>",countusers(),"</font> </b></font></p>\n"; print "<form name='letters' method='post' action='$scripturl'>\n"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0' background='".$imgpath."/bg.gif'><tr><td><img src='".$imgpath."/poloska.gif'></td></tr></table><br>\n"; print "<table border='1' cellspacing='0' cellpadding='4'>\n"; print " <tr><td align='center' colspan='2'><p><b><u>Autoresponder Settings</u></b></p></td></tr>\n"; print " <tr><td align='right'><p>'From' name: <input name='namefield' value='$namears' class='edit1'></p></td><td align='right'><p>Add unsubscribe link:<input type='checkbox' name='unlink' value='1' $unlink></p></td></tr>\n"; print " <tr><td align='right'><p>'From' email: <input name='fromfield' value='$fromars' class='edit1'></p></td><td align='right'><p>Send report to admin:<input type='checkbox' name='sendad' value='1' $fromad></p></td></tr>\n"; print " <tr><td colspan='2' align='right'><p>Redirect after registration to:<input class='edit1' size='40' name='redirect' value='$redirect'></p></td>\n"; print "<input type='hidden' name='password' value=$FORM{'password'}>\n"; print " <tr><td colspan='2' align='center'><input class='edit1' type='image' src='".$imgpath."/save_settings.gif' value='Save Settings' onclick=\"document.letters.mode.value='saveletter'\"> <input class='edit1' type='image' src='".$imgpath."/generate.gif' value='Generate HTML Code' name='B4' onclick='document.letters.mode.value=\"code\"'></td></tr>\n"; print "</table>\n"; print "<br>\n"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0' background='".$imgpath."/bg.gif'><tr><td><img src='".$imgpath."/poloska.gif'></td></tr></table>\n"; print "<p><b><u>Edit Messages</u></b></p>\n"; print "<table>\n"; open(FILE,"$FORM{'ar'}/periods.txt"); flock(FILE,$LOCK_EX); foreach(<FILE>) {push(@periods,$_)} close(FILE); @periods[0]=0; $numb=0; opendir(DIR,"@_[0]") || die "Cannot open $userdir!"; while (@files=readdir(DIR)) { foreach $file(@files){ if ($file ne ".." && $file ne "." && $file ne "" && $file=~/letter\d*\.txt/) { push(@list1,$file); @listing=sort blia @list1; @listing[$#listing]=~/(\d+)/; $num=$1; if($numb>$#periods){@periods[$numb]=@periods[$numb-1]+1}; print "<tr><td><p><a href='$scripturl?mode=read&fname=@listing[$#listing]&ar=@_[0]&num=$1&password=$FORM{'password'}'>Message $num</a></p></td><td><p> sent after <INPUT class='edit1' name=@listing[$#listing] size='5' value='@periods[$numb]'> days"; ($pattach)=getattach("$FORM{'ar'}/@listing[$#listing]"); $pattach=~/.*\.(.*)$/; if ($pattach ne ""){ $size=-s "$FORM{'ar'}/upfile$num.$1"; print " with attachment: <font color='red'>$pattach</font> ($size bytes)</p></td></tr>"; } else { print "</p></td></tr>"; } $numb++; } } }; close(DIR); if ($#listing==-1){ print "<tr><td><p>You have no letters!</p></td></tr>"; } else { }; $newlet=$#listing+2; print "</table>"; print "<input class='edit1' type='image' src='".$imgpath."/add_message.gif' value='Add New Message' onclick=\"document.letters.mode.value='newlet'\"> <input class='edit1' type='image' src='".$imgpath."/save_intervals.gif' value='Save Intervals' onclick=\"document.letters.mode.value='saveletter'\"><br><br>\n"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0' background='".$imgpath."/bg.gif'><tr><td><img src='".$imgpath."/poloska.gif'></td></tr></table>\n"; print " <p><b><u>Prospects</u></b><br>Do you want to add new contacts to your 'active prospects' list?<br>Just insert their names and addresses below in the following format:<br><b>John Smith|john\@email.com</b><br>or:<br><b>john\@email.com</b><br>(one address per line)<br>Import prospects into sequence beginning with <b>message number</b> <input class='edit1' name='period' size='2' value='1'></p>\n"; print " <textarea class='edit1' rows='8' name='import' cols='50'></textarea><br>\n"; print " <input class='edit1' type='image' src='".$imgpath."/import.gif' value='Import Prospects' onclick=\"document.letters.mode.value='saveletter'\"> "; print " <input type='image' src='".$imgpath."/export.gif' onclick=\"window.open ('$scripturl?mode=export&ar=$FORM{'ar'}&password=$FORM{'password'}', 'newwindow', config='height=500, width=400, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no'); return false;\"><br><br>\n"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0' background='".$imgpath."/bg.gif'><tr><td><img src='".$imgpath."/poloska.gif'></td></tr></table>\n"; print " <input type='hidden' name='ar' value='@_[0]'><input type='hidden' name='mode'>\n"; $numb++; print " <input type='hidden' name='newone' value='$numb'>\n"; print " <input type='hidden' name='password' value='$FORM{'password'}'>\n"; print "</form><br><br>\n"; print "<!–//LETTERS//–>\n"; &footer; }; sub letterbody{ if (@_[3] ne ""){ $delat="<input type='image' src='".$imgpath."/del_attach.gif' value='Delete Attachment' onclick=\"document.letters.mode.value='delattach'\" class='edit1'>"} print "<!–//LETTERBODY//–>\n"; print <<_html; <form name=letters enctype='multipart/form-data' method=post action='$scripturl'> <p><font size="4"><b>Autoresponder: <a target="main" href="$scripturl?mode=letters&ar=$FORM{'ar'}&password=$FORM{'password'}"><font color=red>$FORM{'ar'}</font></a></b></font></p> <p><b>Edit Message @_[2]</b></p> <input type=hidden name=num value=@_[2]> <input type=hidden name=edit value=yes> <input type=hidden name=password value=$FORM{'password'}> <table border="0" cellpadding="2"> <tr> <td align="right"><p><b>Subject:</b></p></td> <td><input type="text" name="subject" value="@_[0]" size="50" maxlength=100 class='edit1'></td> </tr> <tr> <td valign="top" align="right"><p><b>Body:</b></p></td> <td><textarea rows="10" name="body" cols="70" class='edit1'>@_[1]</textarea></td> </tr> </table> <p><b>Currently attached file: <font color=red>@_[3] $att</font></b> $delat</p><br> <p><b>File to attach: <input type='file' ACCEPT='application/octet-stream' name='upfile@_[2]' class='edit1'></b><br> _html print "<input type=hidden name=ar value=$FORM{'ar'}>"; print "<input type=hidden name=mode>"; print "<input type=hidden name=password value=$FORM{'password'}>"; print "<input type='image' src='".$imgpath."/save_message.gif' value='Save Message' onclick=\"document.letters.mode.value='saveletter'\" class='edit1'>\n"; print "<input type='image' src='".$imgpath."/del_message.gif' value='Delete Message' onclick=\"document.letters.mode.value='delletter'\" class='edit1'>\n"; print <<_html; <p><b>PERSONALIZING YOUR MESSAGES</b> </p> <p>There are four pre-set merge words you may use in Body or Subject to personalize your messages.<br> <ul> <li><b>[FIRSTNAME]</b> will extract your prospect's first name (i.e. 'Hi [FIRSTNAME]' will print 'Hi John!', if your prospect's first name is John).<br> </li> <li><b>[FULLNAME]</b> will print your prospect's whole name (i.e. 'Mr. [FULLNAME],' will print 'Mr. John Smith', if your prospect's name is John Smith).<br> </li> <li><b>[EMAIL]</b> will extract your prospect's e-mail address (i.e. 'Your e-mail address is [EMAIL]' will output 'Your e-mail address is j
|