?
Solved

Dropdown Menu from txt file

Posted on 2005-04-01
5
Medium Priority
?
295 Views
Last Modified: 2013-12-25
I have a perl based forum and I am trying to create a theme switcher.
I am 90% there with earlier help from here.

You can see want I am trying to achieve here: http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl

There are 3 files involved, BoardIndex.pl, List.txt and Switcher.js

List.txt -  A list of installed themes

winter
armystyle1
armystyle2
Blue3d
bluePro
blue_waves
call_of_duty
clean_white
cool_blue
counter_strike
gamezone1
gamezone2
gamezone3
gold_bar
greenPro
mac_revisited
marble
metal
mellow_gold
pastel
shades_of_red
soft_grey
subsilver
wood

Switcher.js - used in the form as part of the Theme Preview

function getSelectedValues (select) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = select.options[i].value;
  return r;
}
function getSelectedTexts (select) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = select.options[i].text;
  return r;
}
function getSelectedIndices (select) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = i;
  return r;
}
function updateAction(theForm, str)
{
  var first = str.split(",")[0];
  if (theForm.action.toString().indexOf("theme=") < 0)
    theForm.action += ",theme=" + first;
  theForm.action = theForm.action.replace(/theme=.*$/, "theme=" + first);
}

BoardIndex.pl - The main file. (I will only paste the relevant section)

CoreLoad('BoardIndex',1);
sub LoadIndex {
      if($URL{'a'} eq 'tog') { &Tog; }
      my($moderate,$postsandtops);
      $gdisable = 1;
      $title = $mbname;
      &header;
      foreach (@catbase) {
            ($nme,$id) = split(/\|/,$_);
            if($id eq $URL{'c'}) { $catid = $id; $catname = $nme; last; }
      }
      if($URL{'c'} ne '') { $dirlist = qq~<a href="$surl">$gtxt{'44'}</a> &nbsp;<b>&#155; &nbsp;$catname~; }
            else { $dirlist = qq~<b>$gtxt{'44'}~; }

      $ebout .= <<"EOT";
<script language="JavaScript" type="text/javascript" src="$switcher"></script>
<form action="http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?p=save" method="POST" name="poster" onSubmit="GetTemplate(0)">
  <div align="center">
    <center>
    <table border="1" width="100%" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
        <td class="win" width="31%" height="38" align="left">
        <b><font size="1">Theme Switcher:</font></b><font size="2">&nbsp;</font>
              <select name="theme" size="1">
              <option value=default>default</option>
              <option value="Blue3d">Blue 3d</option>
              <option value="armystyle1">Army Style1</option>
              <option value="armystyle2">Army Style2</option>
              <option value="blue_pro">Blue Pro</option>
              <option value="blue_waves">Blue Waves</option>
              <option value="call_of_duty">Call of Duty</option>
              <option value="clean_white">Clean White</option>
              <option value="cool_blue">Cool/Blue</option>
              <option value="counter_strike">Counter Strike</option>
              <option value="game_zone">Game Zone One</option>
              <option value="game_zone2">Game Zone Two</option>
              <option value="game_zone3">Game Zone Three</option>
              <option value="goldbar">Goldbar</option>
              <option value="green_pro">Green Pro</option>
              <option value="mac_revisited">Mac Revisited</option>
              <option value="marble">Marble</option>
              <option value="mellow_gold">Mellow Gold</option>
              <option value="metal">Metal</option>
              <option value="pastel">Pastel</option>
              <option value="shades_of_red">Shades of Red</option>
              <option value="soft_grey">Soft Grey</option>
              <option value="subsilver">Sub Silver</option>
              <option value="wood">Wood Style</option>
              </select>&nbsp;&nbsp;
  <input type="button" class="button" value="Preview Theme"  onclick="window.open('http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?b=,theme='+document.poster.theme.value,'themes','align=center,height=500,width=750,resizable=yes,scrollbars=yes,status=yes');">&nbsp;&nbsp;
  <input type="text" name="select" size="18" value="default">&nbsp;&nbsp;
  <input type="button" class="button" value="Select Theme" onclick="this.form.select.value = getSelectedValues (this.form.theme); updateAction(this.form, this.form.select.value);">&nbsp;&nbsp;
  <input type="submit" class="button" name="submit" value="Submit">
</table>
</center>
</div>
</form><p> </p>

The question is: How can I replace the current dropdown menu with one created dynamically from the List.txt

I have managed to write a script that creates the menu but now at a total loss of how to use it.
If I paste the contents in and replace the current menu it just prints the code onto the screen.

themeslist.pl - can be seen working here: http://www.pchelp4free.myby.co.uk/cgi-bin/forum/themeslist.pl

#!/usr/bin/perl
print "Content-type: text/html\n\n";
open (DROP, "/Prefs/List.txt");
      @cat = <DROP>;
print "<select name=\"themes\" size=\"1\">\n";
foreach (@cat) {
print "<option value=\"$_\">$_</option>\n";
}
print "</select>";
close (DROP);

print "</select>\n";

Sorry for the long post, Any help greatly appreciated.
0
Comment
Question by:hatap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
kandura earned 2000 total points
ID: 13680056
Just insert that code into boardindex.pl where you write the static select. Replace the 'print's with '$ebout .=', and it should work:

     if($URL{'c'} ne '') { $dirlist = qq~<a href="$surl">$gtxt{'44'}</a> &nbsp;<b>&#155; &nbsp;$catname~; }
          else { $dirlist = qq~<b>$gtxt{'44'}~; }

     $ebout .= <<"EOT";
<script language="JavaScript" type="text/javascript" src="$switcher"></script>
<form action="http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?p=save" method="POST" name="poster" onSubmit="GetTemplate(0)">
  <div align="center">
    <center>
    <table border="1" width="100%" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
        <td class="win" width="31%" height="38" align="left">
        <b><font size="1">Theme Switcher:</font></b><font size="2">&nbsp;</font>
EOT


    open (DROP, "/Prefs/List.txt");
    @cat = <DROP>;
    $ebout .= "<select name=\"themes\" size=\"1\">\n";
    foreach (@cat) {
        $ebout .= "<option value=\"$_\">$_</option>\n";
    }
    $ebout .= "</select>";
    close (DROP);


    $ebout .= <<EOT;
&nbsp;&nbsp;
  <input type="button" class="button" value="Preview Theme"  onclick="window.open('http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?b=,theme='+document.poster.theme.value,'themes','align=center,height=500,width=750,resizable=yes,scrollbars=yes,status=yes');">&nbsp;&nbsp;
  <input type="text" name="select" size="18" value="default">&nbsp;&nbsp;
  <input type="button" class="button" value="Select Theme" onclick="this.form.select.value = getSelectedValues (this.form.theme); updateAction(this.form, this.form.select.value);">&nbsp;&nbsp;
  <input type="submit" class="button" name="submit" value="Submit">
</table>
</center>
</div>
</form><p> </p>
EOT


print "</select>\n";
0
 
LVL 18

Expert Comment

by:kandura
ID: 13680060
without that last line, of course (bad copy/paste on my side)
0
 

Author Comment

by:hatap
ID: 13680128
Thank's for the quick reply but I just get these errors, I believe I have tried doing it this way.

There was a problem loading a part of the e-blah software. The system administrator may be upgrading this forum. If you continue to receive this error after several minutes, please contact the system administrator. Further information relating to this incident is below (file information).

./BoardIndex.pl

syntax error at ./BoardIndex.pl line 58, near "</div"
syntax error at ./BoardIndex.pl line 63, near "/b></span"
syntax error at ./BoardIndex.pl line 119, near "}"
 (Might be a runaway multi-line << string starting on line 97)
Compilation failed in require at ./Blah.pl line 93.


Full BoardIndex.pl


CoreLoad('BoardIndex',1);
sub LoadIndex {
      if($URL{'a'} eq 'tog') { &Tog; }
      my($moderate,$postsandtops);
      $gdisable = 1;
      $title = $mbname;
      &header;
      foreach (@catbase) {
            ($nme,$id) = split(/\|/,$_);
            if($id eq $URL{'c'}) { $catid = $id; $catname = $nme; last; }
      }
      if($URL{'c'} ne '') { $dirlist = qq~<a href="$surl">$gtxt{'44'}</a> &nbsp;<b>&#155; &nbsp;$catname~; }
            else { $dirlist = qq~<b>$gtxt{'44'}~; }

      $ebout .= <<"EOT";
<script language="JavaScript" type="text/javascript" src="$switcher"></script>
<form action="http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?p=save" method="POST" name="poster" onSubmit="GetTemplate(0)">
  <div align="center">
    <center>
    <table border="1" width="100%" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
        <td class="win" width="31%" height="38" align="left">
        <b><font size="1">Theme Switcher:</font></b><font size="2">&nbsp;</font>
EOT

    open (DROP, "/Prefs/List.txt");
    @cat = <DROP>;
    $ebout .= "<select name=\"theme\" size=\"1\">\n";
    foreach (@cat) {
        $ebout .= "<option value=\"$_\">$_</option>\n";
    }
    $ebout .= "</select>";
    close (DROP);

    $ebout .= <<EOT;
&nbsp;&nbsp;
  <input type="button" class="button" value="Preview Theme"  onclick="window.open('http://www.pchelp4free.myby.co.uk/cgi-bin/forum/Blah.pl?b=,theme='+document.poster.theme.value,'themes','align=center,height=500,width=750,resizable=yes,scrollbars=yes,status=yes');">&nbsp;&nbsp;
  <input type="text" name="select" size="18" value="default">&nbsp;&nbsp;
  <input type="button" class="button" value="Select Theme" onclick="this.form.select.value = getSelectedValues (this.form.theme); updateAction(this.form, this.form.select.value);">&nbsp;&nbsp;
  <input type="submit" class="button" name="submit" value="Submit">
</table>
</center>
</div>
</form><p> </p>
EOT

print "</select>\n";

</table>
</center>
</div>
</form><p> </p>

<table cellspacing="1" width="100%" class="border">
 <tr>
  <td class="win" height="22"><span class="smalltext">&nbsp;$dirlist</b></span></td>
 </tr>
</table><br>
EOT
      if($enews) {
            $news = <<"EOT";
<tr>
  <td class="titlebg"  colspan="5"><b><img src="$images/site_sm.gif"> $mbname $var{'4'}</b></td>
 </tr><tr>
  <td class="win" colspan="5" height="40" align="center">
  <script language="JavaScript" type="text/javascript" src="$newsloc"></script>
  <div align="center" onLoad="start()">
  <ilayer id="ns4slider" width="&{swidth};" height="&{sheight};">
  <layer id="ns4slider1" height="&{sheight};" onmouseover="sspeed=0;" onmouseout="sspeed=332;">
  <script language="JavaScript">
EOT
            fopen(FILE,"$prefs/News.txt");
            @newsdisplay = <FILE>;
            fclose(FILE);
            chomp(@newsdisplay);
            $number = 0;
            foreach $message (@newsdisplay) {
                  &BC;
                  $message =~ s/\r//;
                  $message =~ s/'/\\'/;
                  $news .= "singletext[$number]='$message'\n";
                  $temp = $message;
                  ++$number;
            }
            if($number == 1) { $news .= "singletext[$number]='$temp'\n"; }
            elsif(!$number) {
                  $mbname =~ s/'/\\'/;
                  $news .= "  singletext[0]='$mbname $var{'4'}'\n  singletext[1]='$mbname $var{'4'}'\n";
            }
            $news .= <<"EOT";
  </script>
  </layer></ilayer>
  <script language="JavaScript">
  if(document.all){
   document.writeln('<div style="cursor:default;position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
   document.writeln('<div id="ieslider1" style="position:relative;width:'+swidth+';">')
   document.write(singletext[0])
   document.writeln('</div></div>')
  }
  if(document.getElementById&&!document.all){
   document.writeln('<div style="cursor:default;position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
   document.writeln('<div id="ns6slider1" style="position:relative;width:'+swidth+';">')
   document.write(singletext[0])
   document.writeln('</div></div>')
  }
  window.onload = start;
  </script></span>
  </div>
  </td>
 </tr>
EOT
      }

      $ebout .= <<"EOT";
<table cellpadding="5" cellspacing="1" class="border" width="100%">
 $news<tr>
  <td class="titlebg" colspan="2" align="center"><b>$boardindex[2]</b></td>
  <td class="titlebg" width="55" align="center"><span class="smalltext"><b>$boardindex[3]</span></b></td>
  <td class="titlebg" width="55" align="center"><span class="smalltext"><b>$boardindex[4]</span></b></td>
  <td class="titlebg" width="200" align="center"><b>$boardindex[5]</b></td>
 </tr>
EOT
      fopen(FILE,"$prefs/Active.txt");
      @activelist = <FILE>;
      fclose(FILE);
      $activecnt = @activelist;
      chomp @activelist;
      $hidec = 0;
      $memcnt = 0;
      $gcnt = 0;

      foreach(@activelist) {
            ($luser,$ltime,$hidden,$t,$bview) = split(/\|/,$_);
            loaduser($luser);
            if($userset{$luser}->[1] eq '') { $fndu = $luser; } else { $fndu = $userset{$luser}->[1]; }
            push(@quicksort,"$fndu|$luser|$hidden|$bview");
      }

      foreach(sort{lc($a) cmp lc($b)} @quicksort) {
            ($t,$luser,$hidden,$bview) = split(/\|/,$_);
            ++$B{$bview};
            if($userset{$luser}->[1] ne '') {
                  $lostuser = $permissions{$membergrp{$luser},'color'} ? qq~<font color="$permissions{$membergrp{$luser},'color'}"><b>$userset{$luser}->[1]</b></font>~ : $userset{$luser}->[1];
                  if($hidden) {
                        ++$hidec;
                        if($members{'Administrator',$username}) { $memberson .= qq~<a href="$scripturl,v=memberpanel,a=view,u=$luser">$lostuser</a>, ~; }
                              else { next; }
                  } else {
                        ++$memcnt;
                        $memberson .= qq~<a href="$scripturl,v=memberpanel,a=view,u=$luser">$lostuser</a>, ~;
                  }
            } elsif($botsearch{$luser}) {
                  $memberson .= qq~<span class="onlinebots">$botsearch{$luser}</span>, ~;
                  ++$memcnt;
            } else { ++$gcnt; }
      }

      $bcnt = 0; $bp = 0; $bt = 0; $catcnt = 0;

      if($username ne 'Guest') {
            fopen(FILE,"$members/$username.log");
            @logged = <FILE>;
            fclose(FILE);
            chomp @logged;
      }
      if($settings[33]) { $link = "$surl,v=mindex,n=1,b="; } else { $link = "$surl".'b='; }

      foreach(split(/\|/,$Osettings[42])) { $catshow{$_} = 1; }

      foreach(@boardbase) {
            ($id) = split("/",$_);
            $board{$id} = $_;
      }

      foreach(@catbase) {
            ($t,$boardid,$t,$t,$t,$subcats) = split(/\|/,$_);
            $catbase{$boardid} = $_;
            if(!$URL{'c'} && $subcats) {
                  foreach(split(/\//,$subcats)) { $noshow{$_} = 1; }
            }
            push(@cats,$boardid);
      }

      foreach(@cats) {
            if($noshow{$_} || $URL{'c'} && $URL{'c'} ne $_) { next; }
            ($name,$boardid,$memgroups,$boardlist,$message,$subcats) = split(/\|/,$catbase{$_});

            if(GetMemberAccess($memgroups) == 0) { next; }

            BC(); $catdesc = $message ? qq~<tr><td colspan="6" class="win3"><span class="smalltext"><div style="padding-left: 3px; line-height: 130%;">$message</div></span></td></tr>~ : '';

            $rollup = !$catshow{$boardid} ? 'minimize' : 'expand';
            $rollup = $username ne 'Guest' ? qq~<a href="$scripturl,a=tog,cat=$boardid"><img src="$images/$rollup.gif" border="0"></a>~ : '';
            $ebout .= <<"EOT";
<tr>
 <td colspan="6" class="catbg">
  <table cellpadding="1" cellspacing="0" width="100%">
   <tr>
    <td class="catbgtext"><b><a href="$scripturl,c=$boardid">$name</a></b></td>
    <td align="right" valign="top">$rollup</td>
   </tr>
  </table>
 </td>
</tr>$catdesc
EOT
            if($catshow{$boardid}) { $catdisabled = 1; next; }
            if($boardlist eq '') { GetSubCats(); next; }
            foreach $bid (split("/",$boardlist)) {
                  if($board{$bid} eq '') { next; } # Invalid board data
                  ($t,$message,$binfo[1],$binfo[2],$binfo[3],$binfo[4],$binfo[5],$binfo[6],$t,$t,$binfo[9],$t,$t,$redir) = split("/",$board{$bid});

                  $lastuser = $lastdate = $icon = $bstat = $postsandtops = $infrm = '';

                  if(GetMemberAccess($binfo[9]) == 0) { next; }

                  # Get the post totals
                  fopen(FILE,"$boards/$bid.ino");
                  @postinfo = <FILE>;
                  fclose(FILE);
                  chomp @postinfo;
                  $posts  = $postinfo[1] > 0 ? MakeComma($postinfo[1]) : 0;
                  $topics = $postinfo[0] > 0 ? MakeComma($postinfo[0]) : 0;

                  # Compile the mods list
                  @mods = split(/\|/,$binfo[1]);
                  &Mods;
                  if($modz) { $modz = qq~<div class="smalltext" style="line-height: 200%;"><b>$ltxt[7]:</b> $modz</div>~; }

                  # Users browsing
                  if($sauser && $B{$bid}) { $infrm = qq~ ($B{$bid} $boardindex[45])~; }

                  # Get last thread info (and look in log for new threads)
                  fopen(FILE,"$boards/$bid.msg");
                  while(<FILE>) {
                        chomp;
                        ($t,$mtitle,$t,$t,$t,$t,$t,$icon,$lastdate,$lastuser) = split(/\|/,$_);
                        $icon = $icon ne 'xx' ? qq~<img src="$images/$icon.gif">~ : '';
                        last;
                  }
                  fclose(FILE);

                  GetBoardData($mtitle,$lastdate,$lastuser,$bid);

                  if($foundnew) { $new = 'off'; $alt = $boardindex[9]; }
                        else { $new = 'on'; $alt = $boardindex[10]; }

                  # Restricted posting?
                  if(!GetMemberAccess($binfo[3])) { $bstat = qq~<div class="smalltext" style="line-height: 200%;"><b>$boardindex[6]</b></div>~; }
                  if(!GetMemberAccess($binfo[3]) && !GetMemberAccess($binfo[4])) { $new = "locked"; }

                  # Basic board info (like description)
                  $message =~ s/&#47;/\//gsi;
                  &BC;

                  # Info blocked by permissions?
                  if($binfo[6]) {
                        $bstat .= qq~<div class="smalltext" style="line-height: 200%;"><b>$boardindex[7]</b></div>~;
                        if(($Blah{"$bid\_pw"} ne $binfo[6] && !$members{'Administrator',$username}) || $username eq 'Guest') {
                              $icon = '';
                              $lastpost = $gtxt{'13'};
                              $bt -= $postinfo[0];
                              $bp -= $postinfo[1];
                              $topics = $posts = '?';
                              $new = 'locked';
                              $lastdate = 1;
                        }
                  }

                  # Redirect forum, or regular?
                  if($redir) {
                        fopen(ADD,"$boards/$bid.hits");
                        $nump = MakeComma( <ADD> ) || 0;
                        fclose(ADD);

                        $postsandtops = <<"EOT";
  <td class="win" align="center" colspan="2"><span class="smalltext"><b>$boardindex[71]:</b> $nump</span></td>
EOT
                        $icon = '';
                        $lastpost = $boardindex[72];
                        $new = 'redirect';
                        $bid = $bid.'" target="_top"';
                  } else {
                        $postsandtops = <<"EOT";
  <td class="win" align="center"><b>$topics</b></td>
  <td class="win" align="center"><b>$posts</b></td>
EOT
                        $bp += $postinfo[1];
                        $bt += $postinfo[0];
                  }
                  ++$bcnt;

                  $ebout .= <<"EOT";
 <tr>
  <td class="win" align="center" width="25" valign="top" style="padding: 7px;"><img src="$images/$new.gif" alt="$alt"></td>
  <td class="win2" valign="top"><b><a href="$link$bid">$binfo[2]</a></b><span class="smalltext">$infrm<div style="line-height: 130%; padding-left: 2px;">$message$bstat$modz</div></span></td>
$postsandtops
  <td class="win2" width="205"><table cellpadding="2" cellspacing="0">
   <tr>
    <td width="20" align="center">$icon</td>
    <td valign="top" width="190"><span class="smalltext">$lastpost</span></td>
   </tr>
  </table></td>
 </tr>
EOT
            }
            if($subcats) { GetSubCats(); }
            ++$catcnt;
      }

      if($bcnt == 0 && !$catdisabled) {
            $ebout .= <<"EOT";
 <tr>
  <td class="win" align="center" colspan="5"><br>$boardindex[14]<br><br></td>
 </tr>
EOT
      } else {
            if($username ne 'Guest' && $amar && $URL{'c'} eq '') { $maread = qq~<span class="smalltext"><a href="$scripturl,v=mark,l=bindex">$img{'markread'}</a></span>~; }
            if($settings[15] > 0) { $settings[15] = "+$settings[15]"; }
            if($settings[15]) { $timezone = " $settings[15] $gtxt{'3'}"; }
            $ebout .= <<"EOT";
<tr>
 <td colspan="5" class="catbg">
  <table cellpadding="0" cellspacing="0" width="100%">
   <tr>
    <td class="catbgtext"><span class="smalltext">$boardindex[67]$timezone</span></td>
    <td class="catbgtext" align="right">$maread</td>
   </tr>
  </table>
 </td>
</tr>
EOT
      }
      if($bcnt == 1) { $r = $boardindex[49]; } else { $r = $boardindex[50]; }
      $bp = MakeComma($bp);
      $bt = MakeComma($bt);
      if(!$lasttopic) { $lasttopic = $boardindex[24]; }
      $ebout .= <<"EOT";
</table>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
 <tr>
  <td align="left" valign="top" width="50%">
   <table cellpadding="4" cellspacing=1 class="border" width="100%">
    <tr>
     <td class="titlebg"  colspan="2"><b><img src="$images/open_thread.gif" style="vertical-align: middle"> $boardindex[18]</b></td>
    </tr><tr>
     <td class="win2" align="center" width="33"><img src="$images/boardinfo.gif"></td>
     <td class="win2">
      <table cellpadding="2" cellspacing="0" width="100%">
       <tr><td colspan="2"><span class="smalltext"><b>$boardindex[19]</b></span></td><td align="right" colspan="2"><span class="smalltext"><b><a href="$scripturl,v=portal">$boardindex[48]</a></b></span></td></tr>
       <tr><td colspan="4" height="2" class="border"></td></tr>
       <tr><td width="150"><span class="smalltext"><b>$gtxt{'6'}:</b></span></td><td><span class="smalltext">$catcnt</span></td><td width="150"><span class="smalltext"><b>$gtxt{'7'}:</b></span></td><td><span class="smalltext">$bcnt</span></td></tr>
       <tr><td><span class="smalltext"><b>$gtxt{'8'}:</b></span></td><td><span class="smalltext">$bt</span></td><td><span class="smalltext"><b>$gtxt{'9'}:</b></span></td><td><span class="smalltext">$bp</span></td></tr>
       <tr><td colspan="2" align="center"><span class="smalltext">$lasttopic</span></td><td colspan="2" align="center"><span class="smalltext"><a href="$scripturl,v=search,p=topten">$boardindex[25]</a></span></td></tr>
      </table></td>
    </tr>
EOT
      if(($eclick && (!$hideclog || $members{'Administrator',$username})) || ($uextlog && (!$hideelog || $members{'Administrator',$username}))) {
            fopen(FILE,"$prefs/ClickLog.txt");
            while (<FILE>) { ++$clcnt; }
            fclose(FILE);
            $logcnt = $logcnt > 59 ? sprintf("%.0f",($logcnt/60))." $gtxt{'3'}" : "$logcnt $gtxt{'2'}";
            $clcnt = MakeComma($clcnt);
            $ebout .= <<"EOT";
    <tr>
     <td class="win" align="center"><img src="$images/clicklog.gif"></td>
     <td class="win">
      <table cellpadding="2" cellspacing="0" width="100%">
EOT
            if($eclick && (!$hideclog || $members{'Administrator',$username})) {
                  $ebout .= <<"EOT";
     <tr><td><span class="smalltext">$boardindex[51] <b>$logcnt</b> $boardindex[52] <b>$clcnt $boardindex[53]</b>.</b></span></td></tr>
EOT
            }
            if($uextlog  && (!$hideelog || $members{'Administrator',$username})) { $ebout .= qq~<tr><td><span class="smalltext"><b><a href="$scripturl,v=stats">$boardindex[22] $boardindex[21]</a></b></span></td></tr>~; }
            $ebout .= <<"EOT";
      </table>
     </td>
    </tr>
EOT
            $dacolor = 'win2';
      } else { $dacolor = 'win'; }
      if($showevents) {
            CoreLoad('Calendar');
            ($t,$t,$t,$tday,$thismon,$qyear) = gmtime(time+(3600*($settings[15]+$settings[31]+$gtoff)));
            if($enbdays) { &GetBirthdays; }
            &GetEvents;

            if($upevents) { # Upcoming eventz
                  for($c = 1; $c <= $upevents; ++$c) {
                        ($t,$t,$t,$ttday,$tthismon,$tyear) = gmtime((time+(3600*($settings[15]+$settings[31]+$gtoff)))+(86400*$c));
                        $temp = $Events{"$tthismon|$ttday|$tyear"}.$Events{"$tthismon|$ttday|90"};
                        foreach(@useonce) {
                              if($temp =~ /\Q$_\E/) {
                                    if($used{$_}) { $temp =~ s~\Q$_\E~~gis; }
                                    $used{$_} = 1;
                              }
                        }
                        $tom .= $temp;
                  }
            }
            $tom =~ s/, \Z//;

            if($enbdays) {
                  $bdays = $BirthDay{"$thismon|$tday"};
                  $bdays =~ s/, \Z//;
                  $bdays = $bdays || "<i>$boardindex[46]</i>"; # None!
            }

            $events = $Events{"$thismon|$tday|$qyear"}.$Events{"$thismon|$tday|90"};
            $events =~ s/, \Z//;
            $events = $events || "<i>$boardindex[46]</i>"; # None!

            $ebout .= <<"EOT";
    <tr>
     <td class="$dacolor" align="center"><img src="$images/cal_sm.gif"></td>
     <td class="$dacolor">
      <table cellpadding="2" cellspacing="0" width="100%">
EOT
            if($Events{"$thismon|$tday|$qyear"} || $Events{"$thismon|$tday|90"} || $BirthDay{"$thismon|$tday"}) {
                  $ebout .= <<"EOT";
<tr><td colspan="2"><span class="smalltext"><b>$boardindex[27]</b></span></td></tr>
<tr><td colspan="2" height="2" class="border"></td></tr>
EOT
                  if($enbdays) { $ebout .= qq~<tr><td width="80" valign="top"><span class="smalltext"><b>$bdaysc $boardindex[28]:</b></span></td><td><span class="smalltext">$bdays</span></td></tr>~; }
                  $ebout .= <<"EOT";
<tr><td width="80" valign="top"><span class="smalltext"><b>$eventsc $boardindex[29]:</b></span></td><td><span class="smalltext">$events</span></td></tr>
EOT
            } else { $ebout .= qq~<tr><td><span class="smalltext"><b>$boardindex[30] $boardindex[31]</b></span></td></tr>~; }

            if($tom) {
                  $ebout .= <<"EOT";
<tr><td colspan="2"><span class="smalltext"><br><b>$boardindex[70]</b></span></td></tr>
<tr><td colspan="2" height="2" class="border"></td></tr>
<tr><td colspan="2"><span class="smalltext">$tom</span></td></tr>
EOT
            }
            $ebout .= <<"EOT";
      </table>
     </td>
    </tr>
EOT
      }
      $ebout .= <<"EOT";
   </table>
  </td>
  <td>&nbsp;</td>
  <td align="right" valign="top" width="50%">
   <table cellpadding="4" cellspacing="1" class="border" width="100%">
    <tr>
     <td class="titlebg" colspan="2"><b><img src="$images/profile_sm.gif" style="vertical-align: middle"> $boardindex[32]</b></td>
    </tr>
EOT
      fopen(FILE,"$members/LastMem.txt");
      @lm = <FILE>;
      fclose(FILE);
      chomp @lm;

      $memberson =~ s/, \Z//i;
      if($memberson eq '') { $memberson = "<i>$boardindex[69]</i>"; }

      fopen(FILE,"$prefs/MaxLog.txt");
      @maxlogged = <FILE>;
      fclose(FILE);
      chomp @maxlogged;
      $maxtime = get_date($maxlogged[1]);

      loaduser($lm[0]);
      $allcnt = MakeComma($gcnt+$hidec+$memcnt);
      $lm[1] = MakeComma($lm[1]);
      $ebout .= <<"EOT";
    <tr>
     <td class="win" align="center" width="33"><img src="$images/online.gif"></td>
     <td class="win">
      <table cellpadding="2" cellspacing="0" width="100%">
       <tr><td><span class="smalltext"><b>$allcnt $boardindex[54] $activeuserslog $gtxt{'2'}</b></span></td></tr>
       <tr><td height="2" class="border"></td></tr>
       <tr><td><span class="smalltext"><b>$memcnt $boardindex[56]</b> ($boardindex[66] $hidec $boardindex[57]) $boardindex[68] <b>$gcnt $boardindex[59]</b> $boardindex[58]</b></span></td></tr>
       <tr><td><span class="smalltext">$memberson</span></td></tr>
EOT
      if($whereis) { $ebout .= qq~<tr><td><span class="smalltext"><b><a href="$scripturl,v=stats,a=whereis">$boardindex[36]</a></b></span></td></tr>~; }
      $ebout .= <<"EOT";
      </table>
     </td>
    </tr>
    <tr>
     <td class="win2" align="center"><img src="$images/profile_lg.gif"></td>
     <td class="win2">
      <table cellpadding="2" cellspacing="0" width="100%">
       <tr><td><span class="smalltext">$boardindex[64] $lm[1] $boardindex[65].
       <br>$boardindex[63] "<b><a href="$scripturl,v=memberpanel,a=view,u=$lm[0]">$userset{$lm[0]}->[1]</a></b>".
       <br><a href="$scripturl,v=members"><b>$boardindex[60]</b></a>.
       <br>$boardindex[61] <b>$maxlogged[0]</b> $boardindex[62] <b>$maxtime</b>.</span></td></tr>
      </table>
     </td>
    </tr>
EOT
      if($invfri && $username ne 'Guest') { CoreLoad('Invite'); &InviteBI; }
      $ebout .= <<"EOT";
   </table>
  </td>
 </tr><tr>
  <td colspan="3">&nbsp;</td>
</tr>
EOT
      if($username eq 'Guest') { $ebout .= qq~<tr><td colspan="3"><br>$guestlogin</td></tr>~; }
      $ebout .= "</table>";

      &footer;
      exit;
}

sub Tog {
      if($username eq 'Guest') { &error($boardindex[73].'-register-'); }
      is_member();
      VerifyBoard(); # So someone can't overload the datafile ...
      my($delMZ);
      $URL{'cat'} =~ s~\A\s+~~; # As always ... hack protection
      $URL{'cat'} =~ s~\s+\Z~~;
      $URL{'cat'} =~ s~[\n\r]~~g;

      $Osettings[42] = '';
      foreach(split(/\|/,$settings[42])) {
            if($URL{'cat'} eq $_) { $delMZ = 1; next; }
            $Osettings[42] .= "$_|";
      }
      if(!$delMZ && $catallow{"$URL{'cat'}"}) { $Osettings[42] .= "$URL{'cat'}"; }

      fopen(FILE,"+>$members/$username.dat");
      for($q = 0; $q < $usersetcount; $q++) { print FILE "$Osettings[$q]\n"; }
      fclose(FILE);
}

sub GetBoardData {
      my($mtitle,$lastdate,$lastuser,$board) = @_;
      my($found,$isnew,$tdate);

      $tdate = get_date($lastdate);
      if($username ne 'Guest') {
            foreach $log (@logged) {
                  ($lboard,$lasttime) = split(/\|/,$log);
                  if($lboard eq $board || $lboard eq 'AllBoards') {
                        $isnew = $lasttime-$lastdate;
                        if($isnew >= 0) { $found = 1; }
                        last;
                  }
            }
      }
      $foundnew = $username eq 'Guest' || $found || $lastdate eq '' ? 1 : 0;

      # Get last post info
      loaduser($lastuser);
      if($userset{$lastuser}->[1]) { $lpby = qq~<a href="$scripturl,v=memberpanel,a=view,u=$lastuser">$userset{$lastuser}->[1]</a>~; }
            else { $lpby = CensorList($lastuser); }
      $mtitle = CensorList($mtitle);
      if(length($mtitle) > 24) { $mtitle = substr($mtitle,0,22)."..."; }
      $lpin = $mtitle ne '' ? qq~<a href="$surl,b=$board,v=display,m=latest">~.$mtitle."</a>" : $gtxt{'13'};
      $lastpost = $lpby ne '' ? qq~<div><b>$lpin</b></div><div><b>$boardindex[11]:</b> $lpby</div><div align="right">$tdate</div>~ : $gtxt{'13'};

      if($max < $lastdate) { $max = $lastdate; $lasttopic = qq~<a href="$surl,b=$board,v=display,m=latest" title="$boardindex[13]">$mtitle</a>~; }
}

sub GetMSubs {
      my($msubcats,@boards);
      $noloop{$_[0]} = 1;
      ($t,$t,$t,$boardlist,$t,$msubcats) = split(/\|/,$catbase{$_[0]});
      push(@boardlists, split(/\//,$boardlist) );

      if($msubcats) { foreach $subcat (split(/\//,$msubcats)) { GetMSubs($subcat); } }
}

sub GetSubCats {
      my($cats,$msubcats);
      @boardlists = ();
      foreach $nohere (split(/\//,$subcats)) {
            if($catbase{$nohere} eq '') { next; }
            $subboards = $maxlastdate = 0;
            $icon = $sflist = $lastpost = $posts = $topics = '';
            ($name,$t,$memgroups,$boardlist,$message,$msubcats) = split(/\|/,$catbase{$nohere});
            &BC;
            if(!GetMemberAccess($memgroups)) { next; }
            @boardlists = split(/\//,$boardlist);

            foreach $subcat (split(/\//,$msubcats)) { GetMSubs($subcat); }
            foreach $board (@boardlists) {
                  ++$subboards;
                  ($daid,$t,$t,$sflname,$t,$t,$t,$binfo[6],$t,$t,$grp,$t,$t,$redir) = split("/",$board{$board});
                  if($binfo[6] ne '' && (($Blah{"$board\_pw"} ne $binfo[6] && !$members{'Administrator',$username}) || $username eq 'Guest')) { next; }

                  if($subboards <= 4 && GetMemberAccess($grp)) { $sflist .= qq~<a href="$surl,b=$daid">$sflname</a>, ~; }
                  if($redir) { next; }

                  # Get the post totals
                  fopen(FILE,"$boards/$board.ino");
                  @postinfo = <FILE>;
                  fclose(FILE);
                  chomp @postinfo;
                  $posts  += $postinfo[1];
                  $topics += $postinfo[0];
                  $bp += $postinfo[1];
                  $bt += $postinfo[0];
                  ++$bcnt;

                  fopen(FILE,"$boards/$board.msg");
                  while(<FILE>) {
                        chomp;
                        ($t,$mtitle,$t,$t,$t,$t,$t,$icon,$lastdate,$lastuser) = split(/\|/,$_);
                        if($lastdate > $maxlastdate) { $maxlastdate = $lastdate; $lastpost = "$board|$mtitle|$icon|$lastuser"; }
                        last;
                  }
                  fclose(FILE);
            }
            $sflist =~ s/, \Z//g;
            if($sflist eq '') { $sflist = $boardindex[46]; }

            if($lastpost) {
                  ($board,$mtitle,$icon,$lastuser) = split(/\|/,$lastpost);
                  GetBoardData($mtitle,$maxlastdate,$lastuser,$board);

                  $icon = $icon ne 'xx' && $icon ne '' ? qq~<img src="$images/$icon.gif">~ : '';

                  if($foundnew) { $new = 'cat_off'; $alt = $boardindex[9]; }
                        else { $new = 'cat_on'; $alt = $boardindex[10]; }
            } else { $new = 'cat_off'; $alt = $boardindex[9]; $lastpost = $gtxt{'13'}; }

            $posts  = MakeComma($posts);
            $topics = MakeComma($topics);

            $ebout .= <<"EOT";
 <tr>
  <td class="win" align="center" width="25" valign="top" style="padding: 7px;"><img src="$images/$new.gif" alt="$alt"></td>
  <td class="win2" valign="top"><b><a href="$scripturl,c=$nohere">$name</a></b><span class="smalltext"><div style="line-height: 130%; padding-left: 2px;">$message<div style="line-height: 200%;"><b>$boardindex[74]:</b> $sflist</div></div></span></td>
  <td class="win" align="center"><b>$topics</b></td>
  <td class="win" align="center"><b>$posts</b></td>
  <td class="win2" width="205"><table cellpadding="2" cellspacing="0">
   <tr>
    <td width="20" align="center">$icon</td>
    <td valign="top" width="190"><span class="smalltext">$lastpost</span></td>
   </tr>
  </table></td>
 </tr>
EOT
            $catdisabled = 1;
      }
}
1;
0
 

Author Comment

by:hatap
ID: 13680195
Please ignore my last, it's working, I can't thank you enough kandura
I removed the EOF after </form> it it's working a treat.
0
 
LVL 18

Expert Comment

by:kandura
ID: 13680203
excellent :-)
0

Featured Post

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question