Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With What May Be A Simple Calculation Error

    Hi,

    I was given a cgi/perl script the other day and in running the script and
    it's components everything worked fine when I installed it on my Linux server. However, the end result is that the add message feature keeps multiplying the message number on the URL (which is used to access the message that has been saved).


    I am a PRE-Newbie and have yet to even begin tutorials, but the code and it's package was given to me and I'd like to make the most of it. I think I've placed in the code where the problem is happening, but because I do not know/code perl, i do not know how to remedy it.

    In my search to find answers I've come upon some cgi/perl tutorials - but I
    simply can't at this time, wait for this problem to be solved as I am supposed to be offering it shortly.

    Would you be able to take a look at the code and advise me?

    I think the problem has something to do with the calculations... either the ++2 or the [#] relat=ed to the message number commands.

    I have attached an image of what the resulting code looks like when it is running on the Linux server.


    *this is the section where I believe the problem is happening:


    PHP Code:
    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=~/letterd*.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=-"$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;
    }; 

    I am willing to pay for the fix.
    Your help is appreciated.

    Lilac
    Attached Thumbnails Attached Thumbnails Help With What May Be A Simple Calculation Error-au-messagenumerror.png  


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •