D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Sources\DoSmilies.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\DoSmilies.pl
############################################################################### ###############################################################################
# DoSmilies.pl                                                                # # DoSmilies.pl                                                                #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5 Anniversary Edition                                # # Version:        YaBB 2.5.2                                                  #
# Packaged:       July 04, 2010                                               # # Packaged:       September 30, 2012                                          #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #    
#               Your source for web hosting, web design, and domains.         #    
############################################################################### ###############################################################################
   
$dosmiliesplver = 'YaBB 2.5 AE $Revision: 1.11 $'; $dosmiliesplver = 'YaBB 2.5.2 $Revision: 1.1 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
&LoadLanguage('Main'); &LoadLanguage('Main');
   
sub SmiliePut { sub SmiliePut {
   &print_output_header;     print_output_header(); 
     $moresmilieslist   = q{};  
   $moresmilieslist   = "";     $evenmoresmilies   = q{}; 
   $evenmoresmilies   = "";     $more_smilie_array = q{}; 
   $more_smilie_array = "";     $i                 = 0; 
   $i = 0;     while ( $SmilieURL[$i] ) { 
   while ($SmilieURL[$i]) {          if ( $SmilieURL[$i] =~ /\//ixsm ) { $tmpurl = $SmilieURL[$i]; }  
       if ($SmilieURL[$i] =~ /\//i) { $tmpurl = $SmilieURL[$i]; }        else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }
       else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }          if ( $i && ( $i / 10 ) == int( $i / 10 ) ) {  
       $moresmilieslist .= qq~<br />~ if $i && ($i / 10) == int($i / 10);             $moresmilieslist .= qq~</tr>\n<tr>~; 
       $moresmilieslist .= qq~<img src="$tmpurl" align="bottom" alt="$SmilieDescription[$i]" border="0" onclick="javascript:MoreSmilies($i)" style="cursor:hand" />$SmilieLinebreak[$i]\n~;         } 
       $smilie_url_array .= qq~"$tmpurl", ~;          $moresmilieslist .=  
       $tmpcode = $SmilieCode[$i];  qq~<td><img src="$tmpurl" alt="$SmilieDescription[$i]" onclick="javascript:MoreSmilies($i)" class="moresmiles" />$SmilieLinebreak[$i]</td>\n~; 
       $tmpcode =~ s/\&quot;/"+'"'+"/g;         $smilie_url_array .= qq~"$tmpurl", ~; 
       &FromHTML($tmpcode);         $tmpcode = $SmilieCode[$i]; 
       $tmpcode =~ s/&#36;/\$/g;         $tmpcode =~ s/\&quot;/"+'"'+"/gxsm;    #'; to keep my text editor happy; 
       $tmpcode =~ s/&#64;/\@/g;         FromHTML($tmpcode); 
       $more_smilie_array .= qq~" $tmpcode", ~;         $tmpcode =~ s/&#36;/\$/gxsm; 
       $i++;         $tmpcode =~ s/&#64;/\@/gxsm; 
   }         $more_smilie_array .= qq~" $tmpcode", ~; 
   if ($showsmdir eq 3 || ($showsmdir eq 2 && $detachblock eq 1)) {         $i++; 
       opendir(DIR, "$smiliesdir");     } 
       @contents = readdir(DIR);     if ( $showsmdir == 3 || ( $showsmdir == 2 && $detachblock == 1 ) ) { 
       closedir(DIR);         opendir DIR, "$smiliesdir"; 
       $smilieslist = "";         @contents = readdir DIR; 
       foreach $line (sort { uc($a) cmp uc($b) } @contents) {         closedir DIR; 
           ($name, $extension) = split(/\./, $line);         $smilieslist = {}; 
           if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {          foreach my $line ( sort { uc $a cmp uc $b } @contents ) {  
               if ($line !~ /banner/i) {             ( $name, $extension ) = split /\./xsm, $line; 
                   $evenmoresmilies .= qq~<br />~ if $i && ($i / 10) == int($i / 10);             if (   $extension =~ /gif/ism 
                   $evenmoresmilies .= qq~<img src='$smiliesurl/$line' align="bottom" alt='$name' border='0' onclick='javascript:MoreSmilies($i)' style='cursor:hand' />\n~;                 || $extension =~ /jpg/ism 
                   $more_smilie_array .= qq~" [smiley=$line]", ~;                 || $extension =~ /jpeg/ism 
                   $i++;                 || $extension =~ /png/ism ) 
               }             { 
           }                 if ( $line !~ /banner/ism ) { 
       }                     if ( $i && ( $i / 4 ) == int( $i / 4 ) ) { 
   }                         $evenmoresmilies .= qq~</tr>\n<tr>~; 
   $more_smilie_array .= qq~""~;                     } 
                     $evenmoresmilies .=  
  qq~<td><img src="$smiliesurl/$line" id="$name" onclick="javascript:MoreSmilies($i)" class="moresmiles" alt="moresmilies" /></td>\n~;  
                     $more_smilie_array .= qq~" [smiley=$line]", ~;  
                     $i++;  
                 }  
             }  
         }  
     }  
     $more_smilie_array .= q~''~;  
   
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$smiltxt{'1'}</title> <title>$smiltxt{'1'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
<link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" /> <link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" />
  <style type="text/css">  
  td {border: #ccc solid thin; text-align:center; height:50px; width:90px;}  
  </style>  
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
function AddText(text) { function AddText(text) {
   if (window.opener && !window.opener.closed) {    if (window.opener && !window.opener.closed) {
       if (opener.document.postmodify.message.createTextRange && opener.document.postmodify.message.caretPos) {               if (opener.document.postmodify.message.createTextRange && opener.document.postmodify.message.caretPos) {       
           var caretPos = opener.document.postmodify.message.caretPos;            var caretPos = opener.document.postmodify.message.caretPos;
           caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?            caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
           text + ' ' : text;            text + ' ' : text;
       } else if (opener.document.postmodify.message.setSelectionRange) {        } else if (opener.document.postmodify.message.setSelectionRange) {
           var selectionStart = opener.document.postmodify.message.selectionStart;            var selectionStart = opener.document.postmodify.message.selectionStart;
           var selectionEnd = opener.document.postmodify.message.selectionEnd;            var selectionEnd = opener.document.postmodify.message.selectionEnd;
           var replaceString = text + opener.document.postmodify.message.value.substring(selectionStart, selectionEnd);            var replaceString = text + opener.document.postmodify.message.value.substring(selectionStart, selectionEnd);
           opener.document.postmodify.message.value = opener.document.postmodify.message.value.substring(0, selectionStart) + replaceString + opener.document.postmodify.message.value.substring(selectionEnd);            opener.document.postmodify.message.value = opener.document.postmodify.message.value.substring(0, selectionStart) + replaceString + opener.document.postmodify.message.value.substring(selectionEnd);
           opener.document.postmodify.message.setSelectionRange(selectionStart + text.length, selectionEnd + text.length);            opener.document.postmodify.message.setSelectionRange(selectionStart + text.length, selectionEnd + text.length);
       } else {        } else {
           opener.document.postmodify.message.value += text;            opener.document.postmodify.message.value += text;
       }        }
   }    }
} }
   
moresmiliecode = new Array($more_smilie_array) moresmiliecode = new Array($more_smilie_array)
   
function MoreSmilies(i) { function MoreSmilies(i) {
   AddTxt=moresmiliecode[i];    AddTxt=moresmiliecode[i];
   AddText(AddTxt);    AddText(AddTxt);
} }
// --> // -->
</script> </script>
</head> </head>
<body style="background: #$popback; min-width:400px;"> <body style="background: #$popback; min-width:400px;">
<span style="color: #$poptext;">$smiltxt{'21'}</span><br /><br />~;  <p style="color:#$poptext; text-align:center">$smiltxt{'21'}</p><table><tr>~; 
   
   if ($showadded eq 3 || ($showadded eq 2 && $detachblock eq 1)) {    if ($showadded eq 3 || ($showadded eq 2 && $detachblock eq 1)) {
       $output .= qq~ $moresmilieslist ~;        $output .= qq~ $moresmilieslist ~;
   }    }
   
   $output .= qq~    $output .= qq~
   $evenmoresmilies    $evenmoresmilies
  </tr></table>  
</body> </body>
</html>~; </html>~;
   
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
sub SmilieIndex { sub SmilieIndex {
   &print_output_header;    &print_output_header;
   
   $i = 0;    $i = 0;
   $offset = 0;    $offset = 0;
   $smilieslist = "";    $smilieslist = "";
   $smilie_code_array = "";    $smilie_code_array = "";
   if ($showadded eq 3 || ($showadded eq 2 && $detachblock eq 1)) {    if ($showadded eq 3 || ($showadded eq 2 && $detachblock eq 1)) {
       while ($SmilieURL[$i]) {        while ($SmilieURL[$i]) {
           if ($i % 4 == 0 && $i != 0) {            if ($i % 4 == 0 && $i != 0) {
               $smilieslist .= qq~      </tr>\n      <tr>\n~;                $smilieslist .= qq~      </tr>\n      <tr>\n~;
               $offset++;                $offset++;
           }            }
           if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }            if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }
           else { $smiliescolor = qq~class="windowbg"~; }            else { $smiliescolor = qq~class="windowbg"~; }
           if ($SmilieURL[$i] =~ /\//i) { $tmpurl = $SmilieURL[$i]; }            if ($SmilieURL[$i] =~ /\//i) { $tmpurl = $SmilieURL[$i]; }
           else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }            else { $tmpurl = qq~$defaultimagesdir/$SmilieURL[$i]~; }
           $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor><img src="$tmpurl" border="0" alt="" onclick='javascript:MoreSmilies($i)' style='cursor:hand' /><br /><font size="1" color="#$poptext">$SmilieDescription[$i]</font></td>\n~;            $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor><img src="$tmpurl" border="0" alt="" onclick='javascript:MoreSmilies($i)' style='cursor:hand' /><br /><font size="1" color="#$poptext">$SmilieDescription[$i]</font></td>\n~;
           $smilie_url_array .= qq~"$tmpurl", ~;            $smilie_url_array .= qq~"$tmpurl", ~;
           $tmpcode = $SmilieCode[$i];            $tmpcode = $SmilieCode[$i];
           $tmpcode =~ s/\&quot;/"+'"'+"/g;            $tmpcode =~ s/\&quot;/"+'"'+"/g;
           &FromHTML($tmpcode);            &FromHTML($tmpcode);
           $tmpcode =~ s/&#36;/\$/g;            $tmpcode =~ s/&#36;/\$/g;
           $tmpcode =~ s/&#64;/\@/g;            $tmpcode =~ s/&#64;/\@/g;
           $more_smilie_array .= qq~" $tmpcode", ~;            $more_smilie_array .= qq~" $tmpcode", ~;
           $i++;            $i++;
       }        }
   }    }
   if ($showsmdir eq 3 || ($showsmdir eq 2 && $detachblock eq 1)) {    if ($showsmdir eq 3 || ($showsmdir eq 2 && $detachblock eq 1)) {
       opendir(DIR, "$smiliesdir");        opendir(DIR, "$smiliesdir");
       @contents = readdir(DIR);        @contents = readdir(DIR);
       closedir(DIR);        closedir(DIR);
       foreach $line (sort { uc($a) cmp uc($b) } @contents) {        foreach $line (sort { uc($a) cmp uc($b) } @contents) {
           ($name, $extension) = split(/\./, $line);            ($name, $extension) = split(/\./, $line);
           if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {            if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {
               if ($line !~ /banner/i) {                if ($line !~ /banner/i) {
                   if ($i % 4 == 0 && $i != 0) {                    if ($i % 4 == 0 && $i != 0) {
                       $smilieslist .= qq~      </tr>\n      <tr>\n~;                        $smilieslist .= qq~      </tr>\n      <tr>\n~;
                       $offset++;                        $offset++;
                   }                    }
                   if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }                    if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }
                   else { $smiliescolor = qq~class="windowbg"~; }                    else { $smiliescolor = qq~class="windowbg"~; }
                   $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor><img src="$smiliesurl/$line" border="0" alt="" onclick="javascript:MoreSmilies($i)" style="cursor:hand" /><br /><font size="1" color="#$poptext">$line</font></td>\n~;                    $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor><img src="$smiliesurl/$line" border="0" alt="" onclick="javascript:MoreSmilies($i)" style="cursor:hand" /><br /><font size="1" color="#$poptext">$line</font></td>\n~;
                   $more_smilie_array .= qq~" [smiley=$line]", ~;                    $more_smilie_array .= qq~" [smiley=$line]", ~;
                   $i++;                    $i++;
               }                }
           }            }
       }        }
   }    }
   while ($i % 4 != 0) {    while ($i % 4 != 0) {
       if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }        if (($i + $offset) % 2 == 0) { $smiliescolor = qq~class="windowbg2"~; }
       else { $smiliescolor = qq~class="windowbg"~; }        else { $smiliescolor = qq~class="windowbg"~; }
       $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor>&nbsp;</td>\n~;        $smilieslist .= qq~          <td align="center" valign="middle" height="60" $smiliescolor>&nbsp;</td>\n~;
       $i++;        $i++;
   }    }
   $smilie_code_array .= qq~""~;    $smilie_code_array .= qq~""~;
   $more_smilie_array .= qq~""~;    $more_smilie_array .= qq~""~;
   if (-e "$smiliesdir/banner.gif") { $smiliesheader = qq~<tr><td colspan="4" bgcolor="#$popback" align="center"><img src="$smiliesurl/banner.gif" alt="" /></td></tr>~; }    if (-e "$smiliesdir/banner.gif") { $smiliesheader = qq~<tr><td colspan="4" bgcolor="#$popback" align="center"><img src="$smiliesurl/banner.gif" alt="" /></td></tr>~; }
   else { $smiliesheader = qq~<tr><td colspan="4" align="center"><b><font size="2">$smiltxt{'21'}</font></b></td></tr>~; }    else { $smiliesheader = qq~<tr><td colspan="4" align="center"><b><font size="2">$smiltxt{'21'}</font></b></td></tr>~; }
   
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$smiltxt{'1'}</title> <title>$smiltxt{'1'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
<link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" /> <link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" />
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
function AddText(text) { function AddText(text) {
   if (window.opener && !window.opener.closed) {    if (window.opener && !window.opener.closed) {
       if (opener.document.postmodify.message.createTextRange && opener.document.postmodify.message.caretPos) {        if (opener.document.postmodify.message.createTextRange && opener.document.postmodify.message.caretPos) {
           var caretPos = opener.document.postmodify.message.caretPos;            var caretPos = opener.document.postmodify.message.caretPos;
           caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?            caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
           text + ' ' : text;            text + ' ' : text;
       } else if (opener.document.postmodify.message.setSelectionRange) {        } else if (opener.document.postmodify.message.setSelectionRange) {
           var selectionStart = opener.document.postmodify.message.selectionStart;            var selectionStart = opener.document.postmodify.message.selectionStart;
           var selectionEnd = opener.document.postmodify.message.selectionEnd;            var selectionEnd = opener.document.postmodify.message.selectionEnd;
           var replaceString = text + opener.document.postmodify.message.value.substring(selectionStart, selectionEnd);            var replaceString = text + opener.document.postmodify.message.value.substring(selectionStart, selectionEnd);
           opener.document.postmodify.message.value = opener.document.postmodify.message.value.substring(0, selectionStart) + replaceString + opener.document.postmodify.message.value.substring(selectionEnd);            opener.document.postmodify.message.value = opener.document.postmodify.message.value.substring(0, selectionStart) + replaceString + opener.document.postmodify.message.value.substring(selectionEnd);
           opener.document.postmodify.message.setSelectionRange(selectionStart + text.length, selectionEnd + text.length);            opener.document.postmodify.message.setSelectionRange(selectionStart + text.length, selectionEnd + text.length);
       } else {        } else {
           opener.document.postmodify.message.value += text;            opener.document.postmodify.message.value += text;
       }        }
   }    }
} }
   
moresmiliecode = new Array($more_smilie_array) moresmiliecode = new Array($more_smilie_array)
function MoreSmilies(i) { function MoreSmilies(i) {
   AddTxt=moresmiliecode[i];    AddTxt=moresmiliecode[i];
   AddText(AddTxt);    AddText(AddTxt);
} }
//--> //-->
</script> </script>
</head> </head>
<body style="background: #$popback; min-width:400px;"> <body style="background: #$popback; min-width:400px;">
   <table border="0" cellpadding="4" cellspacing="1" class="bordercolor">    <table border="0" cellpadding="4" cellspacing="1" class="bordercolor">
$smiliesheader $smiliesheader
     <tr>      <tr>
$smilieslist $smilieslist
     </tr>      </tr>
   </table>    </table>
</body> </body>
</html>~; </html>~;
   
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
1; 1;