1###############################################################################
2# ManageTemplates.pm                                                          #
3# $Date: 12.02.14 $                                                           #
4###############################################################################
5# YaBB: Yet another Bulletin Board                                            #
6# Open-Source Community Software for Webmasters                               #
7# Version:        YaBB 2.6.11                                                 #
8# Packaged:       December 2, 2014                                            #
9# Distributed by: http://www.yabbforum.com                                    #
10# =========================================================================== #
11# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved.     #
12# Software by:  The YaBB Development Team                                     #
13#               with assistance from the YaBB community.                      #
14###############################################################################
15use CGI::Carp qw(fatalsToBrowser);
16our $VERSION = '2.6.11';
17
18$managetemplatespmver = 'YaBB 2.6.11 $Revision: 1615 $';
19if ( $action eq 'detailedversion' ) { return 1; }
20
21LoadLanguage('Templates');
22LoadLanguage('Menu');
23$admin_images = "$yyhtml_root/Templates/Admin/default";
24
25sub ModifyTemplate {
26    is_admin_or_gmod();
27    my @tempnames = qw ( Bdaylist BoardIndex Calendar Display Downloads HelpCentre Loginout Memberlist MessageIndex MyCenter MyMessage MyPosts MyProfile Poll Post Other Register Search );
28    my ( $fulltemplate, $line );
29    if    ( $FORM{'templatefile'} ) { $templatefile = $FORM{'templatefile'} }
30    elsif ( $INFO{'templatefile'} ) { $templatefile = $INFO{'templatefile'} }
31    else                            { $templatefile = 'default/default.html'; }
32    opendir TMPLDIR, $templatesdir;
33    @temptemplates = readdir TMPLDIR;
34    closedir TMPLDIR;
35    $templs = q{};
36
37    foreach my $file (@temptemplates) {
38        if ( -e "$templatesdir/$file/$file.html" ) {
39            push @templates, $file;
40        }
41        else {
42            next;
43        }
44    }
45
46    foreach my $name ( sort @templates ) {
47        $selected = q{};
48        if ( -e "$templatesdir/$name/$name.html" ) {
49            $cmp_templatefile = "$name/$name.html";
50            if ( $cmp_templatefile eq $templatefile ) {
51                $selected = q~ selected="selected"~;
52            }
53            $templs .=
54qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~;
55            $selected = q{};
56        }
57        elsif ( -e "$templatesdir/$name/$name.htm" ) {
58            $cmp_templatefile = "$name/$name.htm";
59            if ( $cmp_templatefile eq $templatefile ) {
60                $selected = q~ selected="selected"~;
61            }
62            $templs .=
63qq~<option value="$cmp_templatefile"$selected>$cmp_templatefile</option>\n~;
64            $selected = q{};
65        }
66
67        for my $tmp (@tempnames) {
68            $tmpnm = lc $tmp;
69            ${ 'cmp_' . $tmpnm } = "$name/$tmp.template";
70            if ( -e "$templatesdir/$name/$tmp.template" ) {
71                $ext = $tmp;
72                if ( ${ 'cmp_' . $tmpnm } eq $templatefile ) {
73                    $selected = q~ selected="selected"~;
74                }
75            $templs .=
76qq~<option value="$name/$ext.template"$selected>$name/$ext</option>\n~;
77            $selected = q{};
78            }
79        }
80    }
81
82    fopen( TMPL, "$templatesdir/$templatefile" );
83    while ( $line = <TMPL> ) {
84        $line =~ s/[\r\n]//gxsm;
85        $line =~ s/&nbsp;/&#38;nbsp;/gxsm;
86        $line =~ s/&amp;/&#38;amp;/gxsm;
87        $line =~ s/^\s+//gsm;
88        $line =~ s/\s+$//gsm;
89        FromHTML($line);
90        $fulltemplate .= qq~$line\n~;
91    }
92    fclose(TMPL);
93
94    $yymain .= qq~
95<div class="bordercolor rightboxdiv">
96    <table class="border-space pad-cell">
97        <tr>
98            <td class="titlebg">
99                $admin_img{'xx'} <b> $templ_txt{'52'}</b> - $templatefile
100                <span class="small">(<a href="$adminurl?action=modskin2"><b>$templ_txt{'configure'}</b></a>)</span>
101            </td>
102        </tr>
103    </table>
104    <table class="border-space pad-cell" style="margin-bottom:.5em">
105            <td class="windowbg2">
106                <div style="float: left; width: 40%; padding: 3px;"><label for="templatefile"><b>$templ_txt{'10'}</b>$templ_txt{'10b'}</label></div>
107                <div style="float: left; width: 59%;">
108                    <form action="$adminurl?action=modtemp" method="post" style="display: inline;" accept-charset="$yymycharset">
109                        <select name="templatefile" id="templatefile" size="1" onchange="submit()">
110                    $templs
111                        </select>
112                    </form>
113                </div>
114            </td>
115        </tr>
116    </table>
117</div>
118<form action="$adminurl?action=modtemp2" method="post" style="display: inline;" accept-charset="$yymycharset">
119<div class="bordercolor borderstyle rightboxdiv">
120    <table class="border-space pad-cell" style="table-layout: fixed; margin-bottom: .5em;">
121        <tr>
122            <td class="windowbg2 center">
123                <textarea rows="20" cols="95" name="template" style="width:99%; height: 350px; font-family:Courier">$fulltemplate</textarea>
124                <input type="hidden" name="filename" value="$templatefile" />
125            </td>
126        </tr>
127    </table>
128</div>
129<div class="bordercolor rightboxdiv">
130<table class="border-space pad-cell" style="margin-bottom: .5em;">
131    <tr>
132        <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
133    </tr><tr>
134        <td class="catbg center">
135            <input type="submit" value="$admin_txt{'10'} $templatefile" class="button" />
136        </td>
137    </tr>
138</table>
139</div>
140</form>
141~;
142    $yytitle     = "$admin_txt{'216'}";
143    $action_area = 'modtemp';
144    AdminTemplate();
145    return;
146}
147
148sub ModifyTemplate2 {
149    is_admin_or_gmod();
150    $FORM{'template'} =~ tr/\r//d;
151    $FORM{'template'} =~ s/\A\n//xsm;
152    $FORM{'template'} =~ s/\n\Z//xsm;
153    if   ( $FORM{'filename'} ) { $templatefile = $FORM{'filename'}; }
154    else                       { $templatefile = 'default.html'; }
155    fopen( TMPL, ">$templatesdir/$templatefile" );
156
157    print {TMPL} "$FORM{'template'}\n" or croak "$croak{'print'} TMPL";
158    fclose(TMPL);
159    $yySetLocation = qq~$adminurl?action=modtemp;templatefile=$templatefile~;
160    redirectexit();
161    return;
162}
163
164sub ModifySkin {
165    is_admin_or_gmod();
166
167    if   ( $INFO{'templateset'} ) { $thistemplate = $INFO{'templateset'}; }
168    else                          { $thistemplate = "$template"; }
169
170    foreach my $curtemplate (
171        sort { $templateset{$a} cmp $templateset{$b} }
172        keys %templateset
173      )
174    {
175        $selected = q{};
176        if ( $curtemplate eq $thistemplate ) {
177            $selected    = q~ selected="selected"~;
178            $akttemplate = $curtemplate;
179        }
180        $templatesel .=
181          qq~<option value="$curtemplate"$selected>$curtemplate</option>\n~;
182    }
183
184    (
185        $aktstyle,   $aktimages,  $akthead,     $aktboard,
186        $aktmessage, $aktdisplay, $aktmycenter, $aktmenutype, $aktthreadtools, $aktposttools
187    ) = split /\|/xsm, $templateset{$akttemplate};
188    $thisimagesdir = "$yyhtml_root/Templates/Forum/$aktimages";
189
190    $ttoolschecked = q{};
191    if ( $INFO{'threadtools'} ne q{} ) {
192        if ($INFO{'threadtools'} == 1 ) {
193            $ttoolschecked = ' checked="checked"';
194        }
195    }
196    elsif ( $aktthreadtools == 1 ) {
197        $ttoolschecked = ' checked="checked"';
198    }
199    elsif ( $threadtools == 1 ) {
200        $ttoolschecked = ' checked="checked"';
201    }
202
203    if ( $aktposttools == 1 || $INFO{'posttools'} == 1 ) {
204        $ptoolschecked = ' checked="checked"';
205    }
206
207    my ( $fullcss, $line );
208    if   ( $INFO{'cssfile'} ) { $cssfile = $INFO{'cssfile'}; }
209    else                      { $cssfile = "$aktstyle.css"; }
210    if   ( $INFO{'imgfolder'} ) { $imgfolder = $INFO{'imgfolder'}; }
211    else                        { $imgfolder = "$aktimages"; }
212    if   ( $INFO{'headfile'} ) { $headfile = $INFO{'headfile'}; }
213    else                       { $headfile = "$akthead.html"; }
214    if ( $INFO{'boardfile'} ) { $boardfile = $INFO{'boardfile'}; }
215    else                      { $boardfile = "$aktboard/BoardIndex.template"; }
216    if ( $INFO{'messagefile'} ) { $messagefile = $INFO{'messagefile'}; }
217    else { $messagefile = "$aktmessage/MessageIndex.template"; }
218    if ( $INFO{'displayfile'} ) { $displayfile = $INFO{'displayfile'}; }
219    else { $displayfile = "$aktdisplay/Display.template"; }
220
221    if ( $INFO{'mycenterfile'} ) { $mycenterfile = $INFO{'mycenterfile'}; }
222    else { $mycenterfile = "$aktmycenter/MyCenter.template"; }
223
224    if ( $INFO{'menutype'} ne q{} ) { $UseMenuType = $INFO{'menutype'}; }
225    else {
226        $UseMenuType = $MenuType;
227        if ( $aktmenutype ne q{} ) { $UseMenuType = $aktmenutype; }
228    }
229
230    if ( $INFO{'threadtools'} ne q{} ) { $useThreadtools = $INFO{'threadtools'}; }
231    else {
232        if ( $thistemplate ne 'Forum default' ) { $useThreadtools = $aktthreadtools; }
233        else { $useThreadtools = $threadtools; }
234    }
235
236    if ( $INFO{'posttools'} ne q{} ) { $usePosttools = $INFO{'posttools'}; }
237    else {
238        $usePosttools = $posttools;
239        if ( $thistemplate ne 'Forum default' ) { $usePosttools = $aktposttools; }
240    }
241
242    if   ( $INFO{'selsection'} ) { $selectedsection = $INFO{'selsection'}; }
243    else                         { $selectedsection = 'vboard'; }
244    my ( $boardsel, $messagesel, $displaysel );
245    if ( $selectedsection eq 'vboard' ) { $boardsel = q~ checked="checked"~; }
246    elsif ( $selectedsection eq 'vmessage' ) {
247        $messagesel = q~ checked="checked"~;
248    }
249    elsif ( $selectedsection eq 'vdisplay' ) {
250        $displaysel = q~ checked="checked"~;
251    }
252    else { $mycentersel = q~ checked="checked"~; }
253
254    opendir TMPLDIR, "$htmldir/Templates/Forum";
255    @styles = readdir TMPLDIR;
256    closedir TMPLDIR;
257    $forumcss = q{};
258    $imgdirs  = q{};
259    foreach my $file ( sort @styles ) {
260        ( $name, $ext ) = split /\./xsm, $file;
261        $selected = q{};
262        if ( $ext eq 'css' ) {
263            if ( $file eq $cssfile ) {
264                $selected = q~ selected="selected"~;
265                $viewcss  = $name;
266            }
267            $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;
268        }
269        if ( -d "$htmldir/Templates/Forum/$file"
270            && $file =~ m{\A[0-9a-zA-Z_\#\%\-\:\+\?\$\&\~\,\@/]+\Z}xsm )
271        {
272            if ( $imgfolder eq $file ) {
273                $imgdirs .=
274                  qq~<option value="$file" selected="selected">$file</option>~;
275                $viewimg = $file;
276            }
277            else { $imgdirs .= qq~<option value="$file">$file</option>~; }
278        }
279    }
280
281    fopen( CSS, "$htmldir/Templates/Forum/$cssfile" )
282      or fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile" );
283    while ( $line = <CSS> ) {
284        $line =~ s/[\r\n]//gxsm;
285        FromHTML($line);
286        $fullcss .= qq~$line\n~;
287    }
288    fclose(CSS);
289
290    opendir TMPLDIR, "$templatesdir";
291    @temptemplates = readdir TMPLDIR;
292    closedir TMPLDIR;
293
294    foreach my $tmpfile (@temptemplates) {
295        if ( -d "$templatesdir/$tmpfile" ) {
296            push @templates, $tmpfile;
297        }
298        else {
299            next;
300        }
301    }
302
303    if    ( $UseMenuType == 0 ) { $menutype0 = ' selected="selected" '; }
304    elsif ( $UseMenuType == 1 ) { $menutype1 = ' selected="selected" '; }
305    elsif ( $UseMenuType == 2 ) { $menutype2 = ' selected="selected" '; }
306
307    $fullcss =~ s/\s{2,}/ /gsm;
308    $boardtemplates   = q{};
309    $messagetemplates = q{};
310    $displaytemplates = q{};
311    $headtemplates    = q{};
312
313    foreach my $name ( sort @templates ) {
314        opendir TMPLSDIR, "$templatesdir/$name";
315        @templatefiles = readdir TMPLSDIR;
316        closedir TMPLSDIR;
317
318        foreach my $file (@templatefiles) {
319            if ( $file eq 'index.html' ) { next; }
320            $thefile = qq~$name/$file~;
321            ( $section, $ext ) = split /\./xsm, $file;
322            $hselected = q{};
323            if ( $ext eq 'html' && $section eq $name ) {
324                $viewhead  = $name;
325                if ( $file eq $headfile ) {
326                    $hselected = q~ selected="selected"~;
327                }
328                $headtemplates .=
329                  qq~<option value="$file"$hselected>$name</option>\n~;
330            }
331            $bselected  = q{};
332            $mselected  = q{};
333            $dselected  = q{};
334            $myselected = q{};
335            if ( $section eq 'BoardIndex' ) {
336                if ( $thefile eq $boardfile ) {
337                    $bselected = q~ selected="selected"~;
338                    $viewboard = $name;
339                }
340                $boardtemplates .=
341                  qq~<option value="$thefile"$bselected>$name</option>\n~;
342            }
343            elsif ( $section eq 'MessageIndex' ) {
344                if ( $thefile eq $messagefile ) {
345                    $mselected   = q~ selected="selected"~;
346                    $viewmessage = $name;
347                }
348                $messagetemplates .=
349                  qq~<option value="$thefile"$mselected>$name</option>\n~;
350            }
351            elsif ( $section eq 'Display' ) {
352                if ( $thefile eq $displayfile ) {
353                    $dselected   = q~ selected="selected"~;
354                    $viewdisplay = $name;
355                }
356                $displaytemplates .=
357                  qq~<option value="$thefile"$dselected>$name</option>\n~;
358            }
359            elsif ( $section eq 'MyCenter' ) {
360                if ( $thefile eq $mycenterfile ) {
361                    $myselected   = q~ selected="selected"~;
362                    $viewmycenter = $name;
363                }
364                $mycentertemplates .=
365                  qq~<option value="$thefile"$myselected>$name</option>\n~;
366            }
367        }
368    }
369
370    fopen( TMPL, "$templatesdir/$viewhead/$viewhead.html" );
371    while ( $line = <TMPL> ) {
372        $line =~ s/^\s+//gsm;
373        $line =~ s/\s+$//gsm;
374        $line =~ s/[\r\n]//gxsm;
375        $fulltemplate .= qq~$line\n~;
376    }
377    fclose(TMPL);
378
379    $tabsep = q{};
380    $tabfill = q{};
381
382    $tempforumurl  = $mbname;
383    $temptitle     = q~Template Config~;
384    $tempnewstitle = qq~<b>$templ_txt{'68'}:</b> ~;
385    $tempnews      = qq~$templ_txt{'84'}~;
386    $tempstyles =
387qq~<link rel="stylesheet" href="$yyhtml_root/Templates/Forum/$viewcss.css" type="text/css" />~;
388    $tempimages    = qq~$yyhtml_root/Templates/Forum/$viewimg~;
389    $tempimagesdir = qq~$htmldir/Templates/Forum/$viewimg~;
390    $tempmenu =
391qq~<ul><li><span class="tabstyle selected" title="$img_txt{'103'}">$tabfill$img_txt{'103'}$tabfill</span></li>~;
392    $tempmenu .=
393qq~<li><span class="tabstyle" title="$img_txt{'119'}" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</span></li>~;
394    $tempmenu .=
395qq~<li><span class="tabstyle" title="$img_txt{'331'}">$tabfill$img_txt{'331'}$tabfill</span></li>~;
396    $tempmenu .=
397qq~<li><span class="tabstyle" title="$img_txt{'mycenter'}">$tabfill$img_txt{'mycenter'}$tabfill</span></li>~;
398    $tempmenu .=
399qq~<li><span class="tabstyle" title="$img_txt{'108'}">$tabfill$img_txt{'108'}$tabfill</span>$tabsep</li></ul>~;
400    $tempmenu =~
401s/img src\=\"$imagesdir\/(.+?)\"/TmpImgLoc($1, $tempimages, $tempimagesdir)/eisgm;
402    $rssbutton = qq~<img src="$imagesdir/rss.png" alt="" />~;
403    $tempuname = qq~$templ_txt{'69'} ${$uid.$username}{'realname'}, ~;
404    $tempuim   = qq~$templ_txt{'70'} <a id="ims">0 $templ_txt{'71'}</a>.~;
405    $temptime  = timeformat( $date, 1 );
406    my $tempsearchbox =
407qq~<form><input type="text" name="search" size="16" id="search1" value="$img_txt{'182'}" style="font-size: 11px;" onfocus="txtInFields(this, '$img_txt{'182'}');" onblur="txtInFields(this, '$img_txt{'182'}')" /><input type="image" src="$imagesdir/search.png" alt="$maintxt{'searchimg'} $showsearchboxnum $maintxt{'searchimg2'}" style="background-color: transparent; margin-right: 5px; vertical-align: middle;" /></form>
408~;
409    $altbrdcolor = q~windowbg2~;
410    $boardtable = q~id="General"~;
411    $templatejump  = 1;
412    $tempforumjump = jumpto();
413
414    $fulltemplate =~ s/({|<)yabb bottom(}|>)//gsm;
415    $fulltemplate =~ s/({|<)yabb fixtop(}|>)//gsm;
416    $fulltemplate =~ s/({|<)yabb javascripta(}|>)//gsm;
417    $fulltemplate =~ s/({|<)yabb javascript(}|>)//gsm;
418    $fulltemplate =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
419    $fulltemplate =~ s/({|<)yabb mycharset(}|>)/$yymycharset/gsm;
420    $fulltemplate =~ s/({|<)yabb title(}|>)/$temptitle/gsm;
421    $fulltemplate =~ s/({|<)yabb style(}|>)/$tempstyles/gsm;
422    $fulltemplate =~ s/({|<)yabb html_root(}|>)/$yyhtml_root/gsm;
423    $fulltemplate =~ s/({|<)yabb images(}|>)/$tempimages/gsm;
424    $fulltemplate =~ s/({|<)yabb uname(}|>)/$tempuname/gsm;
425    $fulltemplate =~ s/({|<)yabb boardlink(}|>)/$tempforumurl/gsm;
426    $fulltemplate =~ s/({|<)yabb navigation(}|>)//gsm;
427    $fulltemplate =~ s/({|<)yabb searchbox(}|>)/$tempsearchbox/gsm;
428    $fulltemplate =~ s/({|<)yabb im(}|>)/$tempuim/gsm;
429    $fulltemplate =~ s/({|<)yabb time(}|>)/$temptime/gsm;
430    $fulltemplate =~ s/({|<)yabb langChooser(}|>)//gsm;
431    $fulltemplate =~ s/({|<)yabb menu(}|>)/$temp21menu/gsm;
432    $fulltemplate =~ s/({|<)yabb tabmenu(}|>)/$tempmenu/gsm;
433    $fulltemplate =~ s/({|<)yabb rss(}|>)/$rssbutton/gsm;
434    $fulltemplate =~ s/<span id="newsdiv"><\/span>/<span id="newsdiv">$tempnews<\/span>/gsm;
435    $fulltemplate =~ s/({|<)yabb newstitle(}|>)/$tempnewstitle/gsm;
436    $fulltemplate =~ s/({|<)yabb copyright(}|>)//gsm;
437    $fulltemplate =~ s/({|<)yabb debug(}|>)//gsm;
438    $fulltemplate =~ s/({|<)yabb forumjump(}|>)/$tempforumjump/gsm;
439    $fulltemplate =~ s/({|<)yabb freespace(}|>)//gsm;
440    $fulltemplate =~ s/({|<)yabb navback(}|>)//gsm;
441    $fulltemplate =~ s/({|<)yabb admin_alert(}|>)//gsm;
442    $fulltemplate =~ s/({|<)yabb tabadd(}|>)//gsm;
443    $fulltemplate =~ s/({|<)yabb addtab(}|>)//gsm;
444    $fulltemplate =~ s/({|<)yabb syntax_js(}|>)//gsm;
445    $fulltemplate =~ s/({|<)yabb grayscript(}|>)//gsm;
446    $fulltemplate =~ s/({|<)yabb high(}|>)//gsm;
447    $fulltemplate =~ s/({|<)yabb ubbc(}|>)//gsm;
448    $fulltemplate =~ s/({|<)yabb news(}|>)//gsm;
449## Mod Hook fulltemplate
450## End Mod Hook fulltemplate
451
452    if ( $selectedsection eq 'vboard' ) {
453        $boardtempl = BoardTempl( $viewboard, $tempimages, $tempimagesdir );
454        $fulltemplate =~ s/({|<)yabb main(}|>)/$boardtempl/gsm;
455        $fulltemplate =~ s/({|<)yabb colboardtable(}|>)//gsm;
456        $fulltemplate =~ s/({|<)yabb boardtable(}|>)/$boardtable/gsm;
457        $fulltemplate =~ s/({|<)yabb altbrdcolor(}|>)/$altbrdcolor/gsm;
458    }
459    elsif ( $selectedsection eq 'vmessage' ) {
460        $messagetempl =
461          MessageTempl( $viewmessage, $tempimages, $tempimagesdir );
462        $fulltemplate =~ s/({|<)yabb main(}|>)/$messagetempl/gsm;
463    }
464    elsif ( $selectedsection eq 'vdisplay' ) {
465        $displaytempl =
466          DisplayTempl( $viewdisplay, $tempimages, $tempimagesdir );
467        $fulltemplate =~ s/({|<)yabb main(}|>)/$displaytempl/gsm;
468    }
469    elsif ( $selectedsection eq 'vmycenter' ) {
470        $mycentertempl =
471          MyCenterTempl( $viewmycenter, $tempimages, $tempimagesdir );
472        $fulltemplate =~ s/({|<)yabb main(}|>)/$mycentertempl/gsm;
473    }
474    $fulltemplate =~
475s/img src\=\"$tempimages\/(.+?)\"/TmpImgLoc($1, $tempimages, $tempimagesdir)/eisgm;
476    $fulltemplate =~
477      s/<a href="http:\/\/validator.w3.org\/check\/referer">.+?<\/a>//gsm;
478    $fulltemplate =~
479s/<a href="http:\/\/jigsaw.w3.org\/css\-validator\/validator\?uri\={yabb url}">.+?<\/a>//gsm;
480    $fulltemplate =~ s/[\n\r]//gxsm;
481    ToHTML($fulltemplate);
482
483    $yymain .= qq~
484<form action="$adminurl?action=modskin2" name="selskin" method="post" style="display: inline;" accept-charset="$yymycharset">
485<div class="bordercolor rightboxdiv">
486    <table class="border-space pad-cell">
487        <tr>
488            <td class="titlebg">
489                $admin_img{'xx'} <b> $templ_txt{'6'}</b>
490                <span class="small">(<a href="$adminurl?action=modtemp;"><b>$templ_txt{'edit_files'}</b></a>)</span>
491            </td>
492        </tr>
493    </table>
494    <table class="border-space" style="margin-bottom: -1px;">
495        <tr>
496            <td class="windowbg2 center">
497                <iframe id="TempManager" name="TempManager" style="border:0" scrolling="yes"></iframe>
498            </td>
499        </tr>
500    </table>
501    <table class="border-space pad-cell" style="margin-bottom: .5em;">
502        <tr>
503            <td class="windowbg2">
504                <div style="float: left; width: 30%; padding: 3px;"><label for="templateset"><b>$templ_txt{'10'}</b>$templ_txt{'10b'}</label></div>
505                <div style="float: left; width: 69%;">
506                    <input type="hidden" name="button" value="0" />
507                    <select name="templateset" id="templateset" size="1" onchange="submit();">
508                        $templatesel
509                    </select>
510~;
511    if ( $akttemplate ne 'Forum default' ) {
512        $yymain .=
513qq~                        <input type="submit" value="$templ_txt{'14'}" onclick="document.selskin.button.value = '3'; return confirm('$templ_txt{'15'} $thistemplate?')" class="button" />~;
514    }
515    $yymain .= qq~
516                </div>
517            </td>
518        </tr><tr>
519            <td class="windowbg2">
520                <div style="float: left; width: 30%; padding: 3px;">
521                        <b>$templ_txt{'11'}</b><br /><span class="small">$templ_txt{'7'}</span>
522                </div>
523                <div style="float: left; width: 69%;">
524                    <div style="float: left; width: 32%; text-align: left;">
525                        <label for="menutype"><span class="small">$templ_txt{'521'}</span></label><br />
526                            <select name="menutype" id="menutype" size="1" style="width: 90%;">
527                                <option value="0"$menutype0>$admin_txt{'521a'}</option>
528                                <option value="1"$menutype1>$admin_txt{'521b'}</option>
529                                <option value="2"$menutype2>$admin_txt{'521c'}</option>
530                            </select>
531                        </div>
532                        <div style="float: left; width: 32%; text-align: left;">
533                            <label for="threadtools"><span class="small">$templ_txt{'528'}</span></label><br />
534                            <input type="checkbox" name="threadtools" id="threadtools" value="1"$ttoolschecked />
535                        </div>
536                        <div style="float: left; width: 32%; text-align: left;">
537                            <label for="headfile" class="small">$templ_txt{'527'}</label><br />
538                            <input type="checkbox" name="posttools" id="posttools" value="1"$ptoolschecked />
539                        </div>
540                        <br style="clear:left" />
541                        <div style="float: left; width: 32%; text-align: left;">
542                            <label for="cssfile"><span class="small">$templ_txt{'1'}</span></label><br />
543                            <select name="cssfile" id="cssfile" size="1" style="width: 90%;">
544                                $forumcss
545                            </select>
546                        </div>
547                        <div style="float: left; width: 32%; text-align: left;">
548                            <label for="imgfolder"><span class="small">$templ_txt{'8'}</span></label><br />
549                            <select name="imgfolder" id="imgfolder" size="1" style="width: 90%;">
550                                $imgdirs
551                            </select>
552                        </div>
553                        <div style="float: left; width: 32%; text-align: left;">
554                            <label for="headfile" class="small">$templ_txt{'2'}</label><br />
555                            <select name="headfile" id="headfile" size="1" style="width: 90%;">
556                                $headtemplates
557                            </select>
558                        </div>
559                        <div style="float: left; width: 32%; text-align: left;">
560                            <input type="radio" name="selsection" id="bradio" value="vboard" class="windowbg2" style="border: 0; vertical-align: middle;"$boardsel /><label for="bradio" class="small">$templ_txt{'3'}</label><br />
561                            <select name="boardfile" id="boardfile" size="1" style="width: 90%;">
562                                $boardtemplates
563                            </select>
564                        </div>
565                        <div style="float: left; width: 32%; text-align: left;">
566                            <input type="radio" name="selsection" id="mradio" value="vmessage" class="windowbg2" style="border: 0; vertical-align: middle;"$messagesel /><label for="mradio" class="small">$templ_txt{'4'}</label><br />
567                            <select name="messagefile" id="messagefile" size="1" style="width: 90%;">
568                                $messagetemplates
569                            </select>
570                        </div>
571                        <div style="float: left; width: 32%; text-align: left;">
572                            <input type="radio" name="selsection" id="dradio" value="vdisplay" class="windowbg2" style="border: 0; vertical-align: middle;"$displaysel /><label for="dradio" class="small">$templ_txt{'5'}</label><br />
573                            <select name="displayfile" id="displayfile" size="1" style="width: 90%;">
574                                $displaytemplates
575                            </select>
576                        </div>
577                        <div style="float: left; width: 32%; text-align: left;">
578                            <input type="radio" name="selsection" id="myradio" value="vmycenter" class="windowbg2" style="border: 0; vertical-align: middle;"$mycentersel /><label for="myradio" class="small">$templ_txt{'67'}</label><br />
579                            <select name="mycenterfile" id="mycenterfile" size="1" style="width: 90%;">
580                                $mycentertemplates
581                            </select>
582                        </div>
583                    </div>
584                </td>
585            </tr>
586    </table>
587</div>
588<div class="bordercolor rightboxdiv">
589<table class="border-space pad-cell" style="margin-bottom: .5em;">
590    <tr>
591        <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
592    </tr><tr>
593        <td class="catbg center">
594           <label for="saveas"><b>$templ_txt{'12'}</b></label>
595            <input type="hidden" name="tempname" value="$fulltemplate" />
596            <input type="text" name="saveas" id="saveas" value="$thistemplate" size="30" maxlength="50" />
597            <input type="submit" value="$templ_txt{'13'}" onclick="document.selskin.button.value = '2';" class="button" />
598            <input type="submit" value="$templ_txt{'9'}" onclick="document.selskin.button.value = '1';" class="button" />
599        </td>
600    </tr>
601</table>
602</div>
603</form>
604<script type="text/javascript">
605function updateTemplate() {
606        var thetemplate = document.selskin.tempname.value;
607        thetemplate=thetemplate.replace(/\\&amp\\;/g, "&");
608        thetemplate=thetemplate.replace(/\\&quot\\;/g, '"');
609        thetemplate=thetemplate.replace(/\\&nbsp\\;/g, " ");
610        thetemplate=thetemplate.replace(/\\&\\#124\\;/g, "|");
611        thetemplate=thetemplate.replace(/\\&lt\\;/g, "<");
612        thetemplate=thetemplate.replace(/\\&gt\\;/g, ">");
613        TempManager.document.open("text/html");
614        TempManager.document.write(thetemplate);
615        TempManager.document.close();
616}
617document.onload = updateTemplate();
618</script>
619~;
620    $yytitle     = $templ_txt{'6'};
621    $action_area = 'modskin';
622    AdminTemplate();
623    return;
624}
625
626sub ModifySkin2 {
627    is_admin_or_gmod();
628    $formattemp = $FORM{'templateset'};
629    formatTempname();
630    if ( $FORM{'button'} == 1 ) {
631        $mythreads = 1;
632        if ( $FORM{'threadtools'} eq q{} ) {
633            $mythreads = 0;
634        }
635        $yySetLocation =
636qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'};threadtools=$mythreads;posttools=$FORM{'posttools'}~;
637
638    }
639    elsif ( $FORM{'button'} == 2 ) {
640        $template_name = $FORM{'saveas'};
641        if ( $template_name eq 'default' ) {
642            fatal_error('no_delete_default');
643        }
644        if ( $template_name !~
645            m{\A[0-9a-zA-Z_\ \.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z}sm
646            || $template_name eq q{} )
647        {
648            fatal_error('invalid_template');
649        }
650        ( $template_css, undef, undef ) = split /\./xsm, $FORM{'cssfile'};
651        $template_images = $FORM{'imgfolder'};
652        ( $template_head,     undef ) = split /\./xsm, $FORM{'headfile'};
653        ( $template_board,    undef ) = split /\//xsm, $FORM{'boardfile'};
654        ( $template_message,  undef ) = split /\//xsm, $FORM{'messagefile'};
655        ( $template_display,  undef ) = split /\//xsm, $FORM{'displayfile'};
656        ( $template_mycenter, undef ) = split /\//xsm, $FORM{'mycenterfile'};
657        ( $template_menutype, undef ) = split /\//xsm, $FORM{'menutype'};
658        $template_threadtools = $FORM{'threadtools'} || 0;
659        $template_posttools = $FORM{'posttools'} || 0;
660        $formattemp = $FORM{'saveas'};
661        formatTempname();
662        UpdateTemplates( $template_name, 'save' );
663        $yySetLocation =
664qq~$adminurl?action=modskin;templateset=$formattemp;cssfile=$FORM{'cssfile'};imgfolder=$FORM{'imgfolder'};headfile=$FORM{'headfile'};boardfile=$FORM{'boardfile'};messagefile=$FORM{'messagefile'};displayfile=$FORM{'displayfile'};mycenterfile=$FORM{'mycenterfile'};menutype=$FORM{'menutype'};selsection=$FORM{'selsection'};threadtools=$mythreads;posttools=$FORM{'posttools'}~;
665
666    }
667    elsif ( $FORM{'button'} == 3 ) {
668        $template_name = $FORM{'templateset'};
669        if ( $template_name eq 'default' ) {
670            fatal_error('no_delete_default');
671        }
672        if ( $template_name eq 'Forum default' ) {
673            fatal_error('no_delete_default');
674        }
675        UpdateTemplates( $template_name, 'delete' );
676        $yySetLocation = qq~$adminurl?action=modskin~;
677    }
678    else {
679        $yySetLocation = qq~$adminurl?action=modskin;templateset=$formattemp~;
680    }
681    redirectexit();
682    return;
683}
684
685sub formatTempname {
686    my ($formattemp) = @_;
687    $formattemp =~ s/\%/%25/gsm;
688    $formattemp =~ s/\#/%23/gsm;
689    $formattemp =~ s/\+/%2B/gsm;
690    $formattemp =~ s/\,/%2C/gsm;
691    $formattemp =~ s/\-/%2D/gsm;
692    $formattemp =~ s/\./%2E/gsm;
693    $formattemp =~ s/\@/%40/gsm;
694    $formattemp =~ s/\^/%5E/gsm;
695    return;
696}
697
698sub TmpImgLoc {
699    my @x = @_;
700    if ( !-e "$x[2]/$x[0]" ) {
701        $thisimgloc = qq~img src="$yyhtml_root/Templates/Forum/default/$x[0]"~;
702    }
703    else { $thisimgloc = qq~img src="$x[1]/$x[0]"~; }
704    return $thisimgloc;
705}
706
707sub BoardTempl {
708    my @x = @_;
709    LoadLanguage('BoardIndex');
710    my $tmpimagesdir = $imagesdir;
711    $imagesdir = qq~$x[1]~;
712    require "$templatesdir/$x[0]/BoardIndex.template";
713
714    if ( -e ("$vardir/mostlog.txt") ) {
715        fopen( MOSTUSERS, "$vardir/mostlog.txt" );
716        @mostentries = <MOSTUSERS>;
717        fclose(MOSTUSERS);
718        ( $mostmemb,  $datememb )  = split /\|/xsm, $mostentries[0];
719        ( $mostguest, $dateguest ) = split /\|/xsm, $mostentries[1];
720        ( $mostusers, $dateusers ) = split /\|/xsm, $mostentries[2];
721        ( $mostbots,  $datebots )  = split /\|/xsm, $mostentries[3];
722        chomp $datememb;
723        chomp $dateguest;
724        chomp $dateusers;
725        chomp $datebots;
726        $themostmembdate  = timeformat($datememb);
727        $themostguestdate = timeformat($dateguest);
728        $themostuserdate  = timeformat($dateusers);
729        $themostbotsdate  = timeformat($datebots);
730        $themostuser      = $mostusers;
731        $themostmemb      = $mostmemb;
732        $themostguest     = $mostguest;
733        $themostbots      = $mostbots;
734    }
735    else {
736        $themostmembdate  = timeformat($date);
737        $themostguestdate = timeformat($date);
738        $themostuserdate  = timeformat($date);
739        $themostbotsdate  = timeformat($date);
740        $themostuser      = 23;
741        $themostmemb      = 12;
742        $themostguest     = 19;
743        $themostbots      = 4;
744    }
745
746    $grpcolors = q{};
747    ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
748      $Group{'Administrator'}, 5;
749    my $admcolor = qq~$color~;
750    if ( $color && $noshow != 1 ) {
751        $grpcolors .=
752qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
753    }
754    ( $title, undef, undef, $color, $noshow ) =
755      split /\|/xsm, $Group{'Global Moderator'}, 5;
756    if ( $color && $noshow != 1 ) {
757        $grpcolors .=
758qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
759    }
760    ( $title, undef, undef, $color, $noshow ) =
761      split /\|/xsm, $Group{'Mid Moderator'}, 5;
762    if ( $color && $noshow != 1 ) {
763        $grpcolors .=
764qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
765    }
766    foreach my $nopostamount ( sort { $a <=> $b } keys %NoPost ) {
767        ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
768          $NoPost{$nopostamount}, 5;
769        if ( $color && $noshow != 1 ) {
770            $grpcolors .=
771qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
772        }
773    }
774    foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) {
775        ( $title, undef, undef, $color, $noshow ) = split /\|/xsm,
776          $Post{$postamount}, 5;
777        if ( $color && $noshow != 1 ) {
778            $grpcolors .=
779qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
780        }
781    }
782
783    my $latestmemberlink =
784qq~$boardindex_txt{'201'} <a href="javascript:;"><b>${$uid.$username}{'realname'}</b></a>.<br />~;
785    my $tempims =
786qq~$boardindex_txt{'795'} <a href="javascript:;"><b>2</b></a> $boardindex_txt{'796'} $boardindex_imtxt{'24'} <a href="javascript:;"><b>2</b></a> $boardindex_imtxt{'26'}.~;
787    my $tempforumurl    = $mbname;
788    my $tempnew         = qq~$admin_img{'off'}~;
789    my $tempcurboard    = $templ_txt{'77'};
790    my $tempcurboardurl = q~javascript:;~;
791    my $tempboardanchor = $templ_txt{'78'};
792    my $tempbddescr     = $templ_txt{'79'};
793    my $tempshowmods =
794qq~$boardindex_txt{'63'}: $templ_txt{'74'}<br />$boardindex_txt{'63a'}: $templ_txt{'74a'}~;
795    my $templastposttme = timeformat($date);
796    my $templastpostlink =
797      qq~<a href="javascript:;">$img{'lastpost'}</a> $templastposttme~;
798    my $templastposter =
799      qq~<a href="javascript:;">${$uid.$username}{'realname'}</a>~;
800    my $tmplasttopiclink = qq~<a href="javascript:;">$templ_txt{'80'}</a>~;
801    $tempcatlink =
802qq~<img src="$x[1]/cat_collapse.png" alt="" /> <a href="javascript:;">$templ_txt{'81'}</a>~;
803    my $templatecat = $catheader;
804    $templatecat =~ s/({|<)yabb catlink(}|>)/$tempcatlink/gsm;
805    my $tmptemplateblock = $templatecat;
806    my $templastpostdate = timeformat($date);
807    $templastpostdate = qq~($templastpostdate).<br />~;
808    my $temprecentposts =
809qq~$boardindex_txt{'791'} <select style="font-size: 7pt;"><option>--</option><option>5</option></select> $boardindex_txt{'792'} $boardindex_txt{'793'}~;
810    my $tempguestson =
811      qq~<span class="small">$boardindex_txt{'141'}: <b>2</b></span>~;
812    my $tempbotson =
813      qq~<span class="small">$boardindex_txt{'143'}: <b>3</b></span>~;
814    my $tempbotlist =
815      q~<span class="small">Googlebot (1), MSN Search (2)</span>~;
816    my $tempuserson =
817      qq~<span class="small">$boardindex_txt{'142'}: <b>1</b></span>~;
818    my $tempusers =
819qq~<span class="small" style="color: $admcolor;"><b>${$uid.$username}{'realname'}</b></span><br />~;
820    my $tempmembercount = q~<b>2</b>~;
821    my $tempboardpic =
822      qq~ <img src="$imagesdir/boards.png" alt="$tempcurboard" />~;
823
824    for my $i ( 1 .. 2 ) {
825        my $templateblock = $boardblock;
826        $templateblock =~ s/({|<)yabb new(}|>)/$tempnew/gsm;
827        $templateblock =~ s/({|<)yabb boardrss(}|>)//gsm; ### RSS on Board Index ###
828        $templateblock =~ s/({|<)yabb boardanchor(}|>)/$tempboardanchor_$i/gsm;
829        $templateblock =~ s/({|<)yabb boardurl(}|>)/$tempcurboardurl/gsm;
830        $templateblock =~ s/({|<)yabb boardpic(}|>)/$tempboardpic/gsm;
831        $templateblock =~ s/({|<)yabb boardname(}|>)/$tempcurboard $i/gsm;
832        $templateblock =~ s/({|<)yabb boardviewers(}|>)/$boardviewers/gsm;
833        $templateblock =~ s/({|<)yabb boarddesc(}|>)/$tempbddescr/gsm;
834        $templateblock =~ s/({|<)yabb moderators(}|>)/$tempshowmods/gsm;
835        $templateblock =~ s/({|<)yabb threadcount(}|>)/$i/gsm;
836        $templateblock =~ s/({|<)yabb messagecount(}|>)/$i/gsm;
837        $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/gsm;
838        $templateblock =~ s/({|<)yabb lastposter(}|>)/$templastposter/gsm;
839        $templateblock =~ s/({|<)yabb lasttopiclink(}|>)/$tmplasttopiclink/gsm;
840        $tmptemplateblock .= $templateblock;
841    }
842    $tmptemplateblock .= $catfooter;
843    $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)//sm;
844    $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/gsm;
845    require Sources::Menu;
846    $collapselink = SetImage('collapse', $UseMenuType);
847    $markalllink  = SetImage('markallread', $UseMenuType);
848    $menusep = q{&nbsp;};
849    if ( $UseMenuType == 1 ) {
850        $menusep = q{ | };
851    }
852    my $templasttopiclink =
853qq~$boardindex_txt{'236'} <a href="javascript:;"><b>$templ_txt{'80'}</b></a>~;
854
855    $boardhandellist =~ s/({|<)yabb collapse(}|>)/$menusep$collapselink/gsm;
856    $boardhandellist =~ s/({|<)yabb expand(}|>)//gsm;
857    $boardhandellist =~ s/({|<)yabb markallread(}|>)/$menusep$markalllink/gsm;
858    $boardhandellist =~ s/\Q$menusep//ism;
859    $boardindex_template =~
860      s/({|<)yabb boardhandellist(}|>)/$boardhandellist/gsm;
861    $boardindex_template =~ s/({|<)yabb catimage(}|>)//gsm;
862    $boardindex_template =~ s/({|<)yabb catrss(}|>)//gsm; ### RSS on Board Index ###
863    $boardindex_template =~
864      s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
865
866    $boardindex_template =~ s/({|<)yabb newmsg start(}|>)//gsm;
867    $boardindex_template =~ s/({|<)yabb newmsg icon(}|>)//gsm;
868    $boardindex_template =~ s/({|<)yabb newmsg(}|>)//gsm;
869    $boardindex_template =~ s/({|<)yabb newmsg end(}|>)//gsm;
870
871    $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/3/gsm;
872    $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/3/gsm;
873    $boardindex_template =~
874      s/({|<)yabb lastpostlink(}|>)/$templasttopiclink/gsm;
875    $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$templastpostdate/gsm;
876    $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$temprecentposts/gsm;
877    $boardindex_template =~ s/({|<){yabb recenttopics(}|>)//gsm;
878
879    $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$themostuser/gsm;
880    $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$themostmemb/gsm;
881    $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$themostguest/gsm;
882    $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$themostbots/gsm;
883    $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/gsm;
884    $boardindex_template =~
885      s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/gsm;
886    $boardindex_template =~
887      s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/gsm;
888    $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/gsm;
889    $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/gsm;
890
891    $boardindex_template =~ s/({|<)yabb membercount(}|>)/$tempmembercount/gsm;
892    $boardindex_template =~ s/({|<)yabb expandmessages(}|>)/$temp_expandmessages/gsm;
893    $boardindex_template =~ s/({|<)yabb latestmember(}|>)/$latestmemberlink/gsm;
894    $boardindex_template =~ s/({|<)yabb ims(}|>)/$tempims/gsm;
895    $boardindex_template =~ s/({|<)yabb users(}|>)/$tempuserson/gsm;
896    $boardindex_template =~ s/({|<)yabb spc(}|>)//gsm;
897    $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$tempusers/gsm;
898    $boardindex_template =~ s/({|<)yabb guests(}|>)/$tempguestson/gsm;
899    $boardindex_template =~ s/({|<)yabb onlineguests(}|>)//gsm;
900    $boardindex_template =~ s/({|<)yabb bots(}|>)/$tempbotson/gsm;
901    $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$tempbotlist/gsm;
902    $boardindex_template =~ s/({|<)yabb caldisplay(}|>)/$cal_display/gsm;
903    $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)//gsm;
904    $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//gsm;
905    $boardindex_template =~ s/({|<)yabb new_load(}|>)//gsm;
906    $boardindex_template =~
907                  s/({|<)yabb subboardlist(}|>)//gsm;
908    $boardindex_template =~
909                  s/({|<)yabb messagedropdown(}|>)//gsm;
910## Mod Hook BoardIndex ##
911## End Mod Hook BoardIndex ##
912    $boardindex_template =~
913      s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
914    $boardindex_template =~ s/^\s+//gsm;
915    $boardindex_template =~ s/\s+$//gsm;
916    $imagesdir = $tmpimagesdir;
917    return $boardindex_template;
918}
919
920sub MessageTempl {
921    my @x = @_;
922    LoadLanguage('MessageIndex');
923    my $tmpimagesdir = $imagesdir;
924    $imagesdir = "$x[1]";
925    require "$templatesdir/$x[0]/MessageIndex.template";
926    my $tempcatnm   = $templ_txt{'72'};
927    my $tempboardnm = $templ_txt{'73'};
928    my $tempmodslink =
929qq~($messageindex_txt{'298'}: $templ_txt{'74'} - $messageindex_txt{'298a'}: $templ_txt{'74a'})~;
930    my $tempbdescrip     = $templ_txt{'79'};
931    my $temppageindextgl = qq~<img src="$x[1]/xx.gif" alt="" />~;
932    my $temppageindex =
933qq~<span class="small" style="vertical-align: middle;"> <b>$messageindex_txt{'139'}:</b> 1</span>~;
934    my $tempthreadpic = qq~<img src="$x[1]/thread.gif" alt="" />~;
935    my $tempmicon     = qq~<img src="$x[1]/xx.gif" alt="" />~;
936    my $tempnew       = qq~<img src="$x[1]/new.gif" alt="" />~;
937    my $tempmsublink  = $templ_txt{'83'};
938    my $tempmname     = ${ $uid . $username }{'realname'};
939    my $templastpostlink =
940      qq~<img src="$x[1]/lastpost.gif" alt="" /> $templ_txt{'82'}~;
941    my $templastposter = $tempmname;
942    my $tempyabbicons  = qq~<img src="$x[1]/thread.gif" alt="" /> $messageindex_txt{'457'}<br /><img src="$x[1]/hotthread.gif" alt="" /> $messageindex_txt{'454'} x $messageindex_txt{'454a'}<br /><img src="$x[1]/veryhotthread.gif" alt="" /> $messageindex_txt{'455'} x $messageindex_txt{'454a'}<br /><img src="$x[1]/locked.gif" alt="" /> $messageindex_txt{'456'}<br /><img src="$x[1]/locked_moved.gif" alt="" /> $messageindex_txt{'845'}
943~;
944    my $tempyabbadminicons .= qq~<img src="$x[1]/hide.gif" alt="" /> $messageindex_txt{'458'}<br /><img src="$x[1]/hidesticky.gif" alt="" /> $messageindex_txt{'459'}<br /><img src="$x[1]/hidelock.gif" alt="" /> $messageindex_txt{'460'}<br /><img src="$x[1]/hidestickylock.gif" alt="" /> $messageindex_txt{'461'}<br /><img src="$x[1]/announcement.gif" alt="" /> $messageindex_txt{'779a'}<br /><img src="$x[1]/announcementlock.gif" alt="" /> $messageindex_txt{'779b'}<br /><img src="$x[1]/sticky.gif" alt="" /> $messageindex_txt{'779'}<br /><img src="$x[1]/stickylock.gif" alt="" /> $messageindex_txt{'780'}
945~;
946
947    $bdpic = qq~ <img src="$x[1]/boards.png" alt="$templ_txt{'72'}" /> ~;
948    $message_permalink = $messageindex_txt{'10'};
949    $temp_attachment =
950      qq~<img src="$x[1]/paperclip.gif" alt="$messageindex_txt{'5'}" />~;
951
952    $messageindex_template =~ s/({|<)yabb home(}|>)/$mbname/gsm;
953    $messageindex_template =~ s/({|<)yabb category(}|>)/$tempcatnm/gsm;
954    $messageindex_template =~ s/({|<)yabb board(}|>)/$tempboardnm/gsm;
955    $messageindex_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/gsm;
956    $messageindex_template =~ s/({|<)yabb sortsubject(}|>)/$messageindex_txt{'70'}/gsm;
957    $messageindex_template =~ s/({|<)yabb sortstarter(}|>)/$messageindex_txt{'109'}/gsm;
958    $messageindex_template =~ s/({|<)yabb sortanswer(}|>)/$messageindex_txt{'110'}/gsm;
959    $messageindex_template =~ s/({|<)yabb sortlastpostim(}|>)/$messageindex_txt{'22'}/gsm;
960    $messageindex_template =~ s/({|<)yabb bdpicture(}|>)/$bdpic/gsm;
961    $messageindex_template =~ s/({|<)yabb threadcount(}|>)/1/gsm;
962    $messageindex_template =~ s/({|<)yabb messagecount(}|>)/2/gsm;
963    $boarddescription =~ s/({|<)yabb boarddescription(}|>)/$tempbdescrip/gsm;
964    $messageindex_template =~ s/({|<)yabb description(}|>)/$boarddescription/gsm;
965    $messageindex_template =~ s/({|<)yabb colspan(}|>)/7/gsm;
966
967    $messageindex_template =~
968      s/({|<)yabb pageindex top(}|>)/$temppageindex1/gsm;
969    $messageindex_template =~
970      s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/gsm;
971    $messageindex_template =~ s/({|<)yabb new_load(}|>)//gsm;
972
973    require Sources::Menu;
974    $notify_board = SetImage('notify', $UseMenuType);
975    $markalllink  = SetImage('markboardread', $UseMenuType);
976    $postlink     = SetImage('newthread', $UseMenuType);
977    $polllink     = SetImage('createpoll', $UseMenuType);
978    $menusep = q{&nbsp;};
979    if ( $UseMenuType == 1 ) {
980        $menusep = q{ | };
981    }
982    $topichandellist = q~{yabb notify button}{yabb markall button}~;
983    if ( $useThreadtools == 1 ) {
984        $notify_board = SetImage('notify', 3);
985        ($notify_board_img, $notify_board_txt ) = split /[|]/xsm, $notify_board;
986        $markall_board = SetImage('markboardread', 3);
987        ($markall_board_img, $markall_board_txt ) = split /[|]/xsm, $markall_board;
988        $topichandellist = qq~<td class="post_tools center template" style="width:10em"><div class="post_tools_a">
989        <a href="javascript:quickLinks('threadtools1')">$maintxt{'62'}</a>
990    </div>
991    </td>
992    <td class="center bottom" style="padding:0px; width:0">
993    <div class="right cursor toolbutton_b">
994        <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
995            <li><div class="toolbutton_a" style="background-image: url($notify_board_img)">$notify_board_txt</div></li>
996            <li><div class="toolbutton_a" style="background-image: url($markall_board_img)">$markall_board_txt</div></li>
997        </ul>
998    </div>~;
999    }
1000    $outside_threadtools = q~{yabb new post button}{yabb new poll button}~;
1001    $outside_threadtools =~ s/{yabb new post button}/$menusep$postlink/gsm;
1002    $outside_threadtools =~ s/{yabb new poll button}/$menusep$polllink/gsm;
1003    $topichandellist =~ s/{yabb notify button}/$menusep$notify_board/gsm;
1004    $topichandellist =~ s/{yabb markall button}/$menusep$markalllink/gsm;
1005    $topichandellist     = $outside_threadtools . $topichandellist;
1006
1007    $topichandellist =~ s/\Q$menusep//ism;
1008
1009    $messageindex_template =~
1010      s/({|<)yabb topichandellist(}|>)/$topichandellist/gsm;
1011    $messageindex_template =~
1012      s/({|<)yabb topichandellist2(}|>)/$topichandellist/gsm;
1013    $messageindex_template =~
1014      s/class="post_tools center" style="width:10em"/class="right"/gsm;
1015
1016    $messageindex_template =~ s/({|<)yabb pageindex(}|>)/$temppageindex/gsm;
1017    $messageindex_template =~
1018      s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/gsm;
1019    $messageindex_template =~ s/({|<)yabb admin column(}|>)//gsm;
1020    $messageindex_template =~ s/({|<)yabb outsidethreadtools(}|>)//gsm;
1021    $messageindex_template =~ s/({|<)yabb topicpreview(}|>)//gsm;
1022
1023    my $tempbar = $threadbar;
1024    $tempbar =~ s/({|<)yabb admin column(}|>)//gsm;
1025    $tempbar =~ s/({|<)yabb threadpic(}|>)/$tempthreadpic/gsm;
1026    $tempbar =~ s/({|<)yabb icon(}|>)/$tempmicon/gsm;
1027    $tempbar =~ s/({|<)yabb new(}|>)/$tempnew/gsm;
1028    $tempbar =~ s/({|<)yabb poll(}|>)//gsm;
1029    $tempbar =~ s/({|<)yabb favorite(}|>)//gsm;
1030    $tempbar =~ s/({|<)yabb subjectlink(}|>)/$tempmsublink/gsm;
1031    $tempbar =~ s/({|<)yabb pages(}|>)//gsm;
1032    $tempbar =~ s/({|<)yabb attachmenticon(}|>)/$temp_attachment/gsm;
1033    $tempbar =~ s/({|<)yabb starter(}|>)/$tempmname/gsm;
1034    $tempbar =~ s/({|<)yabb starttime(}|>)/ timeformat($date)/egsm;
1035    $tempbar =~ s/({|<)yabb replies(}|>)/2/gsm;
1036    $tempbar =~ s/({|<)yabb views(}|>)/12/gsm;
1037    $tempbar =~ s/({|<)yabb lastpostlink(}|>)/$templastpostlink/gsm;
1038    $tempbar =~ s/({|<)yabb lastposter(}|>)/$templastposter/gsm;
1039
1040    if ( $accept_permalink == 1 ) {
1041        $tempbar =~ s/({|<)yabb permalink(}|>)/$message_permalink/gsm;
1042    }
1043    else {
1044        $tempbar =~ s/({|<)yabb permalink(}|>)//gsm;
1045    }
1046
1047    $tmptempbar .= $tempbar;
1048
1049    $messageindex_template =~ s/({|<)yabb threadblock(}|>)/$tmptempbar/gsm;
1050    $messageindex_template =~ s/({|<)yabb modupdate(}|>)//gsm;
1051    $messageindex_template =~ s/({|<)yabb modupdateend(}|>)//gsm;
1052    $messageindex_template =~ s/({|<)yabb stickyblock(}|>)//gsm;
1053    $messageindex_template =~ s/({|<)yabb adminfooter(}|>)//gsm;
1054    $messageindex_template =~ s/({|<)yabb icons(}|>)/$tempyabbicons/gsm;
1055    $messageindex_template =~
1056      s/({|<)yabb admin icons(}|>)/$tempyabbadminicons/gsm;
1057    $messageindex_template =~ s/({|<)yabb access(}|>)//gsm;
1058    $messageindex_template =~
1059      s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1060    $messageindex_template =~
1061      s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1062    $messageindex_template =~ s/^\s+//gsm;
1063    $messageindex_template =~ s/\s+$//gsm;
1064    $imagesdir = $tmpimagesdir;
1065    return $messageindex_template;
1066}
1067
1068sub DisplayTempl {
1069    my @x = @_;
1070    LoadLanguage('Display');
1071    my $tmpimagesdir = $imagesdir;
1072    $imagesdir = $x[1];
1073    require "$templatesdir/$x[0]/Display.template";
1074    (
1075        $title,     $stars,      $starpic,    $color,     $noshow,
1076        $viewperms, $topicperms, $replyperms, $pollperms, $attachperms
1077    ) = split /\|/xsm, $Group{'Administrator'};
1078
1079    my $template_home = qq~<span class="nav">$mbname</span>~;
1080    my $tempcatnm     = $templ_txt{'72'};
1081    my $tempboardnm   = $templ_txt{'73'};
1082    my $tempmodslink =
1083qq~($display_txt{'298'}: $templ_txt{'74'} - $display_txt{'298a'}: $templ_txt{'74a'})~;
1084    my $template_prev    = $display_txt{'768'};
1085    my $template_next    = $display_txt{'767'};
1086    my $temppageindextgl = qq~<img src="$x[1]/xx.gif" alt="" />~;
1087    my $temppageindex1 =
1088qq~<span class="small" style="vertical-align: middle;"> <b>$display_txt{'139'}:</b> 1</span>~;
1089
1090## Make Buttons ##
1091    require Sources::Menu;
1092    $replybutton          = SetImage('reply', $UseMenuType);
1093    $pollbutton           = SetImage('addpoll', $UseMenuType);
1094    $notify               = SetImage('notify', $UseMenuType);
1095    $favorite             = SetImage('favorites', $UseMenuType);
1096    $template_sendtopic   = SetImage('sendtopic', $UseMenuType);
1097    $template_print       = SetImage('print', $UseMenuType);
1098    $template_alertmod    = SetImage('alertmod', $UseMenuType);
1099    $template_quote       = SetImage('quote', $UseMenuType);
1100    $template_modify      = SetImage('modify', $UseMenuType);
1101    $template_split       = SetImage('admin_split', $UseMenuType);
1102    $template_delete      = SetImage('delete', $UseMenuType);
1103    $template_print_post  = SetImage('printp', $UseMenuType);
1104    $template_email  = SetImage('email_sm', $UseMenuType);
1105    $template_pm     = SetImage('message_sm', $UseMenuType);
1106    $template_remove = SetImage('admin_rem', $UseMenuType);
1107    $template_splice = SetImage('admin_move_split_splice', $UseMenuType);
1108    $template_lock   = SetImage('admin_lock', $UseMenuType);
1109    $template_hide   = SetImage('hide', $UseMenuType);
1110    $template_sticky = SetImage('admin_sticky', $UseMenuType);
1111    $replybutton          = qq~$menusep$replybutton~;
1112    $pollbutton           = qq~$menusep$pollbutton~;
1113    $notify               = qq~$menusep$notify~;
1114    $favorite             = qq~$menusep$favorite~;
1115    $template_sendtopic   = qq~$menusep$template_sendtopic~;
1116    $template_print       = qq~$menusep$template_print~;
1117    $menusep = q{&nbsp;};
1118    if ( $UseMenuType == 1 ) {
1119        $menusep = q{ | };
1120    }
1121    $outside_threadtools = q~{yabb reply}{yabb poll}~;
1122    $threadhandellist = q~{yabb notify}{yabb favorite}{yabb sendtopic}{yabb print}{yabb markunread}~;
1123    if ( $useThreadtools == 1 ) {
1124        $notify               = SetImage('notify', 3);
1125        ($notify_board_img, $notify_board_txt ) = split /[|]/xsm, $notify;
1126        $favorite             = SetImage('favorites', 3);
1127        ($fav_board_img, $fav_board_txt ) = split /[|]/xsm, $favorite;
1128        $template_sendtopic   = SetImage('sendtopic', 3);
1129        ($send_board_img, $send_board_txt ) = split /[|]/xsm, $template_sendtopic;
1130        $template_print       = SetImage('print', 3);
1131        ($print_board_img, $print_board_txt ) = split /[|]/xsm, $template_print;
1132        $threadhandellist = qq~<td class="post_tools center template" style="width:10em"><div class="post_tools_a">
1133        <a href="javascript:quickLinks('threadtools')">$maintxt{'62'}</a>
1134    </div>
1135    </td>
1136    <td class="center bottom" style="padding:0px; width:0">
1137    <div class="right cursor toolbutton_b">
1138        <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
1139            <li><div class="toolbutton_a" style="background-image: url($notify_board_img)">$notify_board_txt</div></li>
1140            <li><div class="toolbutton_a" style="background-image: url($fav_board_img)">$fav_board_txt</div></li>
1141            <li><div class="toolbutton_a" style="background-image: url($send_board_img)">$send_board_txt</div></li>
1142            <li><div class="toolbutton_a" style="background-image: url($print_board_img)">$print_board_txt</div></li>
1143        </ul>
1144    </div>~;
1145    }
1146
1147    $outside_threadtools =~ s/{yabb reply}/$menusep$replybutton/gsm;
1148    $outside_threadtools =~ s/{yabb poll}/$menusep$pollbutton/gsm;
1149    my $template_threadimage = qq~<img src="$x[1]/thread.gif" alt="" />~;
1150    my $threadurl            = $templ_txt{'75'};
1151    $template_alertmod    = qq~$menusep$template_alertmod~;
1152    $template_quote       = qq~$menusep$template_quote~;
1153    $template_modify      = qq~$menusep$template_modify~;
1154    $template_split       = qq~$menusep$template_split~;
1155    $template_delete      = qq~$menusep$template_delete~;
1156    $template_print_post  = qq~$menusep$template_print_post~;
1157    my $memberinfo        = qq~<span class="small"><b>$title</b></span>~;
1158    my $usernamelink =
1159qq~<span style="color: $color;"><b>${$uid.$username}{'realname'}</b></span><br />~;
1160
1161    for ( 1 .. 5 ) {
1162        $star .= qq(<img src="$x[1]/$starpic" alt="*" />);
1163    }
1164    my $msub     = $templ_txt{'76'};
1165    my $msgimg   = qq~<img src="$x[1]/xx.gif" alt="" />~;
1166    my $messdate = timeformat($date);
1167    my $template_postinfo =
1168      qq~$display_txt{'21'}: ${$uid.$username}{'postcount'}<br />~;
1169    my $template_usertext = qq~${$uid.$username}{'usertext'}<br />~;
1170    my $px = 'px';
1171    my $avatar =
1172qq~<img src="$facesurl/elmerfudd.gif" alt="" style="max-width: 50px; max-height: 50px" />~;
1173    my $message =
1174      qq~$templ_txt{'65'}<br /><a href="javascript:;">$templ_txt{'66'}</a>~;
1175    $template_email  = qq~$menusep$template_email~;
1176    $template_pm     = qq~$menusep$template_pm~;
1177    my $ipimg           = qq~<img src="$imagesdir/ip.gif" alt="" />~;
1178    $template_remove = qq~$menusep$template_remove~;
1179    $template_splice = qq~$menusep$template_splice~;
1180    $template_lock   = qq~$menusep$template_lock~;
1181    $template_hide   = qq~$menusep$template_hide~;
1182    $template_sticky = qq~$menusep$template_sticky~;
1183
1184    $online = qq~<span class="useronline">$maintxt{'60'}</span>~;
1185    for my $i ( 0 .. 1 ) {
1186        my $outblock        = $messageblock;
1187        my $posthandelblock = $posthandellist;
1188        my $contactblock    = $contactlist;
1189
1190        if ( $i == 0 ) {
1191            $css          = q~windowbg~;
1192            $counterwords = q{};
1193        }
1194        else {
1195            $css          = q~windowbg2~;
1196            $counterwords = "$display_txt{'146'} #$i";
1197        }
1198        $posthandelblock =~ s/({|<)yabb modalert(}|>)/$template_alertmod/gsm;
1199        $posthandelblock =~ s/({|<)yabb quote(}|>)/$template_quote/gsm;
1200        $posthandelblock =~ s/({|<)yabb modify(}|>)/$template_modify/gsm;
1201        $posthandelblock =~ s/({|<)yabb split(}|>)/$template_split/gsm;
1202        $posthandelblock =~ s/({|<)yabb delete(}|>)/$template_delete/gsm;
1203        $posthandelblock =~ s/({|<)yabb admin(}|>)/$template_admin/gsm;
1204        $posthandelblock =~ s/({|<)yabb print_post(}|>)/$template_print_post/gsm;
1205        $posthandelblock =~ s/\Q$menusep//ism;
1206        $outside_posttools = qq~{yabb quote}{yabb markquote}~;
1207        $posthandellist = qq~{yabb modalert}{yabb print_post}{yabb modify}{yabb split}{yabb delete}~;
1208        if ( $usePosttools == 1 ) {
1209            $template_alertmod    = SetImage('alertmod', 3);
1210            ($template_alertmod_img, $template_alertmod_txt ) = split /[|]/xsm, $template_alertmod;
1211            $template_modify      = SetImage('modify', 3);
1212            ($template_modify_img, $template_modify_txt ) = split /[|]/xsm, $template_modify;
1213            $template_split       = SetImage('admin_split', 3);
1214            ($template_split_img, $template_split_txt ) = split /[|]/xsm, $template_split;
1215            $template_delete      = SetImage('delete', 3);
1216            ($template_delete_img, $template_delete_txt ) = split /[|]/xsm, $template_delete;
1217            $template_print_post  = SetImage('printp', 3);
1218            ($template_print_post_img, $template_print_post_txt ) = split /[|]/xsm, $template_print_post;
1219            $posthandelblock = qq~<td class="post_tools center dividerbot template" style="width:100px; height: 2em; vertical-align:middle"><div class="post_tools_a">
1220        <a href="javascript:quickLinks('threadtools')">$maintxt{'63'}</a>
1221    </div>
1222    </td>
1223    <td class="center bottom" style="padding:0px; width:0">
1224    <div class="right cursor toolbutton_b">
1225        <ul class="post_tools_menu" id="threadtools" onmouseover="keepLinks('threadtools')" onmouseout="TimeClose('threadtools')">
1226            <li><div class="toolbutton_a" style="background-image: url($template_modify_img)">$template_modify_txt</div></li>
1227            <li><div class="toolbutton_a" style="background-image: url($template_split_img)">$template_split_txt</div></li>
1228            <li><div class="toolbutton_a" style="background-image: url($template_delete_img)">$template_delete_txt</div></li>
1229            <li><div class="toolbutton_a" style="background-image: url($template_print_post_img)">$template_print_post_txt</div></li>
1230        </ul>
1231    </div>~;
1232        }
1233        $contactblock =~ s/({|<)yabb email(}|>)/$template_email/gsm;
1234        $contactblock =~ s/({|<)yabb profile(}|>)//gsm;
1235        $contactblock =~ s/({|<)yabb pm(}|>)/$template_pm/gsm;
1236        $contactblock =~ s/({|<)yabb www(}|>)//gsm;
1237        $contactblock =~ s/({|<)yabb aim(}|>)//gsm;
1238        $contactblock =~ s/({|<)yabb yim(}|>)//gsm;
1239        $contactblock =~ s/({|<)yabb icq(}|>)//gsm;
1240        $contactblock =~ s/({|<)yabb gtalk(}|>)//gsm;
1241        $contactblock =~ s/({|<)yabb skype(}|>)//gsm;
1242        $contactblock =~ s/({|<)yabb myspace(}|>)//gsm;
1243        $contactblock =~ s/({|<)yabb facebook(}|>)//gsm;
1244        $contactblock =~ s/({|<)yabb twitter(}|>)//gsm;
1245        $contactblock =~ s/({|<)yabb youtube(}|>)//gsm;
1246        $contactblock =~ s/({|<)yabb addbuddy(}|>)//gsm;
1247        $contactblock =~ s/\Q$menusep//ism;
1248
1249        $outblock =~ s/({|<)yabb images(}|>)/$tmpimagesdir/gsm;
1250        $outblock =~ s/({|<)yabb messageoptions(}|>)//gsm;
1251        $outblock =~ s/({|<)yabb memberinfo(}|>)/$memberinfo/gsm;
1252        $outblock =~ s/({|<)yabb userlink(}|>)/$usernamelink/gsm;
1253        $outblock =~ s/({|<)yabb stars(}|>)/$star/gsm;
1254        $outblock =~ s/({|<)yabb subject(}|>)/$msub/gsm;
1255        $outblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/gsm;
1256        $outblock =~ s/({|<)yabb msgdate(}|>)/$messdate/gsm;
1257        $outblock =~ s/({|<)yabb replycount(}|>)/$counterwords/gsm;
1258        $outblock =~ s/({|<)yabb count(}|>)//gsm;
1259        $outblock =~ s/({|<)yabb att(}|>)//gsm;
1260        $outblock =~ s/({|<)yabb css(}|>)/$css/gsm;
1261        $outblock =~ s/({|<)yabb gender(}|>)//gsm;
1262        $outblock =~ s/({|<)yabb zodiac(}|>)//gsm;
1263        $outblock =~ s/({|<)yabb age(}|>)//gsm;
1264        $outblock =~ s/({|<)yabb regdate(}|>)//gsm;
1265        $outblock =~ s/({|<)yabb ext_prof(}|>)/$template_ext_prof/gsm;
1266        $outblock =~ s/({|<)yabb location(}|>)//gsm;
1267        $outblock =~ s/({|<)yabb isbuddy(}|>)//gsm;
1268        $outblock =~ s/({|<)yabb useronline(}|>)/$online/gsm;
1269        $outblock =~ s/({|<)yabb postinfo(}|>)/$template_postinfo/gsm;
1270        $outblock =~ s/({|<)yabb usertext(}|>)/$template_usertext/gsm;
1271        $outblock =~ s/({|<)yabb userpic(}|>)/$avatar/gsm;
1272        $outblock =~ s/({|<)yabb message(}|>)/$message/gsm;
1273        $outblock =~ s/({|<)yabb showatt(}|>)//gsm;
1274        $outblock =~ s/({|<)yabb showatthr(}|>)//gsm;
1275        $outblock =~ s/({|<)yabb modified(}|>)//gsm;
1276        $outblock =~ s/({|<)yabb signature(}|>)//gsm;
1277        $outblock =~ s/({|<)yabb signaturehr(}|>)//gsm;
1278        $outblock =~ s/({|<)yabb ipimg(}|>)/$ipimg/gsm;
1279        $outblock =~ s/({|<)yabb ip(}|>)//gsm;
1280        $outblock =~ s/({|<)yabb permalink(}|>)//gsm;
1281        $outblock =~ s/({|<)yabb posthandellist(}|>)/$posthandelblock/gsm;
1282        $outblock =~ s/({|<)yabb outsideposttools(}|>)//gsm;
1283        $outblock =~ s/({|<)yabb admin(}|>)//gsm;
1284        $outblock =~ s/({|<)yabb contactlist(}|>)/$contactblock/gsm;
1285## Mod Hook Outblock ##
1286## End Mod Hook Outblock ##
1287        $tempoutblock .= $outblock;
1288    }
1289    $threadhandellist     = $outside_threadtools . $threadhandellist;
1290    $threadhandellist =~ s/({|<)yabb notify(}|>)/$notify/gsm;
1291    $threadhandellist =~ s/({|<)yabb favorite(}|>)/$favorite/gsm;
1292    $threadhandellist =~ s/({|<)yabb sendtopic(}|>)/$template_sendtopic/gsm;
1293    $threadhandellist =~ s/({|<)yabb print(}|>)/$template_print/gsm;
1294    $threadhandellist =~ s/({|<)yabb markunread(}|>)//gsm;
1295    $threadhandellist =~ s/<td class="dividerbot" colspan="3" style="vertical-align:middle;">/<td class="dividerbot" colspan="2" style="vertical-align:middle;">/gsm;
1296    $threadhandellist =~ s/<td class="post_tools center dividerbot" style="width:100px; height: 2em; vertical-align:middle">/<td class="center dividerbot" style="height: 2em; vertical-align:middle">/gsm;
1297    $threadhandellist =~ s/\Q$menusep//ism;
1298
1299    $adminhandellist =~ s/({|<)yabb remove(}|>)/$template_remove/gsm;
1300    $adminhandellist =~ s/({|<)yabb splice(}|>)/$template_splice/gsm;
1301    $adminhandellist =~ s/({|<)yabb lock(}|>)/$template_lock/gsm;
1302    $adminhandellist =~ s/({|<)yabb hide(}|>)/$template_hide/gsm;
1303    $adminhandellist =~ s/({|<)yabb sticky(}|>)/$template_sticky/gsm;
1304    $adminhandellist =~ s/({|<)yabb multidelete(}|>)/$template_multidelete/gsm;
1305    $adminhandellist =~ s/\Q$menusep//ism;
1306
1307    $display_template =~ s/({|<)yabb pollmain(}|>)//gsm;
1308    $display_template =~ s/({|<)yabb topicviewers(}|>)//gsm;
1309
1310    $display_template =~ s/({|<)yabb home(}|>)/$template_home/gsm;
1311    $display_template =~ s/({|<)yabb category(}|>)/$tempcatnm/gsm;
1312    $display_template =~ s/({|<)yabb board(}|>)/$tempboardnm/gsm;
1313    $display_template =~ s/({|<)yabb moderators(}|>)/$tempmodslink/gsm;
1314    $display_template =~ s/({|<)yabb prev(}|>)/$template_prev/gsm;
1315    $display_template =~ s/({|<)yabb next(}|>)/$template_next/gsm;
1316    $display_template =~
1317      s/({|<)yabb pageindex toggle(}|>)/$temppageindextgl/gsm;
1318    $display_template =~ s/({|<)yabb pageindex top(}|>)/$temppageindex1/gsm;
1319    $display_template =~ s/({|<)yabb pageindex bottom(}|>)/$temppageindex1/gsm;
1320    $display_template =~ s/({|<)yabb bookmarks(}|>)//gsm; # Social Bookmarks
1321    $display_template =~
1322      s/({|<)yabb threadhandellist(}|>)/$threadhandellist/gsm;
1323    $display_template =~
1324      s/({|<)yabb threadhandellist2(}|>)/$threadhandellist/gsm;
1325    $display_template =~ s/({|<)yabb outsidethreadtools(}|>)//gsm;
1326    $display_template =~ s/({|<)yabb threadimage(}|>)/$template_threadimage/gsm;
1327    $display_template =~ s/({|<)yabb threadurl(}|>)/$threadurl/gsm;
1328    $display_template =~ s/({|<)yabb views(}|>)/12/gsm;
1329    $display_template =~ s/({|<)yabb multistart(}|>)//gsm;
1330    $display_template =~ s/({|<)yabb multiend(}|>)//gsm;
1331    $display_template =~ s/({|<)yabb postsblock(}|>)/$tempoutblock/gsm;
1332    $display_template =~ s/({|<)yabb adminhandellist(}|>)/$adminhandellist/gsm;
1333    $display_template =~ s/({|<)yabb forumselect(}|>)//gsm;
1334    $display_template =~ s/({|<)yabb guestview(}|>)//gsm;
1335    $display_template =~ s/({|<)yabb reason(}|>)//gsm;
1336    $display_template =~ s/<td class="dividerbot" style="vertical-align:middle;">/<td class="dividerbot" style="vertical-align:middle;" colspan="2">/gsm;
1337    $display_template =~ s/<td class="post_tools center dividerbot" style="width:100px; height: 2em; vertical-align:middle">/<td class="center dividerbot" style="height: 2em; vertical-align:middle">/gsm;
1338    $display_template =~ s/class="post_tools center" style="width:100px"/class="right"/gsm;
1339    $display_template =~ s/class="post_tools center" style="width:10em"/class="right"/gsm;
1340    $display_template =~ s/class="windowbg2 vtop" style="height:10em" colspan="3"/class="windowbg2 vtop" colspan="4" style="height:10em"/gsm;
1341    $display_template =~ s/class="windowbg vtop" style="height:10em" colspan="3"/class="windowbg vtop" colspan="4" style="height:10em"/gsm;
1342    $display_template =~ s/class="windowbg2 bottom" style="height:12px" colspan="3"/class="windowbg2 bottom" colspan="4" style="height:12px"/gsm;
1343    $display_template =~ s/class="windowbg bottom" style="height:12px" colspan="3"/class="windowbg bottom" colspan="4" style="height:12px"/gsm;
1344    $display_template =~ s/class="windowbg2 bottom" colspan="3"/class="windowbg2 bottom" colspan="4"/gsm;
1345    $display_template =~ s/class="windowbg bottom" colspan="3"/class="windowbg bottom" colspan="4"/gsm;
1346    $display_template =~ s/class="windowbg2 bottom dividertop" colspan="3"/class="windowbg2 bottom dividertop" colspan="4"/gsm;
1347    $display_template =~ s/class="windowbg bottom dividertop" colspan="3"/class="windowbg bottom dividertop" colspan="4"/gsm;
1348    $display_template =~
1349      s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1350    $display_template =~
1351      s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1352    $display_template =~ s/^\s+//gsm;
1353    $display_template =~ s/\s+$//gsm;
1354    $imagesdir = $tmpimagesdir;
1355    return $display_template;
1356}
1357
1358sub MyCenterTempl {
1359    my @x = @_;
1360    LoadLanguage('InstantMessage');
1361    LoadLanguage('MyCenter');
1362    my $tmpimagesdir = $imagesdir;
1363    $imagesdir = $x[1];
1364    require "$templatesdir/$x[0]/MyCenter.template";
1365
1366    $tabsep = q{};
1367    $tabfill = qq~<img src="$imagesdir/tabfill.gif" alt="" />~;
1368
1369    if (   $PM_level == 1
1370        || ( $PM_level == 2 && ( $iamadmin || $iamgmod || $iammod ) )
1371        || ( $PM_level == 3 && ( $iamadmin || $iamgmod ) ) )
1372    {
1373        $yymcmenu .=
1374qq~<span title="$mc_menus{'messages'}" class="selected">$tabsep$tabfill$mc_menus{'messages'}$tabfill</span>
1375                ~;
1376    }
1377
1378    $yymcmenu .=
1379qq~$tabsep<span title="$mc_menus{'profile'}">$tabfill$mc_menus{'profile'}$tabfill</span>~;
1380    $yymcmenu .=
1381qq~$tabsep<span title="$mc_menus{'posts'}">$tabfill$mc_menus{'posts'}$tabfill</span>~;
1382    $yymcmenu .= qq~$tabsep~;
1383
1384    $mycenter_template =~ s/{yabb mcviewmenu}/$MCViewMenu/gsm;
1385    $mycenter_template =~ s/{yabb mcmenu}/$yymcmenu/gsm;
1386    $mycenter_template =~ s/{yabb mcpmmenu}/$MCPmMenu/gsm;
1387    $mycenter_template =~ s/{yabb mcprofmenu}/$MCProfMenu/gsm;
1388    $mycenter_template =~ s/{yabb mcpostsmenu}/$MCPostsMenu/gsm;
1389    $mycenter_template =~ s/{yabb mcglobformstart}/$MCGlobalFormStart/gsm;
1390    $mycenter_template =~
1391      s/{yabb mcglobformend}/ ($MCGlobalFormStart ? "<\/form>" : q{}) /esm;
1392    $mycenter_template =~ s/{yabb mccontent}/$MCContent/gsm;
1393    $mycenter_template =~ s/{yabb mctitle}/$mctitle/gsm;
1394    $mycenter_template =~ s/{yabb selecthtml}/$selecthtml/gsm;
1395
1396    $mycenter_template =~
1397      s/img src\=\"$tmpimagesdir\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1398    $mycenter_template =~
1399      s/img src\=\"$x[1]\/(.+?)\"/TmpImgLoc($1, $x[1], $x[2])/eisgm;
1400    $mycenter_template =~ s/^\s+//gsm;
1401    $mycenter_template =~ s/\s+$//gsm;
1402    $imagesdir = $tmpimagesdir;
1403    return $mycenter_template;
1404}
1405
1406sub UpdateTemplates {
1407    my ( $tempelement, $tempjob ) = @_;
1408    if ( $tempjob eq 'save' ) {
1409        $templateset{"$tempelement"} = "$template_css";
1410        $templateset{"$tempelement"} .= "|$template_images";
1411        $templateset{"$tempelement"} .= "|$template_head";
1412        $templateset{"$tempelement"} .= "|$template_board";
1413        $templateset{"$tempelement"} .= "|$template_message";
1414        $templateset{"$tempelement"} .= "|$template_display";
1415        $templateset{"$tempelement"} .= "|$template_mycenter";
1416        $templateset{"$tempelement"} .= "|$template_menutype";
1417        $templateset{"$tempelement"} .= "|$template_threadtools";
1418        $templateset{"$tempelement"} .= "|$template_posttools";
1419    }
1420    elsif ( $tempjob eq 'delete' ) {
1421        delete $templateset{$tempelement};
1422    }
1423
1424    require Admin::NewSettings;
1425    SaveSettingsTo('Settings.pm');
1426    return;
1427}
1428
1429sub ModifyStyle {
1430    is_admin_or_gmod();
1431    my ( $fullcss, $line, $csstype );
1432    $admincs = 0;
1433    if ( $FORM{'cssfile'} ) {
1434        $cssfile = $FORM{'cssfile'};
1435        $csstype = qq~$htmldir/Templates/Forum/$cssfile~;
1436    }
1437    elsif ( $FORM{'admcssfile'} ) {
1438        $cssfile = $FORM{'admcssfile'};
1439        $csstype = qq~$htmldir/Templates/Admin/$cssfile~;
1440        $admincs = 1;
1441    }
1442    else { $cssfile = 'default.css';
1443        $csstype = qq~$htmldir/Templates/Forum/$cssfile~;
1444    }
1445    opendir TMPLDIR, "$htmldir/Templates/Forum";
1446    @styles = readdir TMPLDIR;
1447    closedir TMPLDIR;
1448
1449    $forumcss = qq~<option value="" disabled="disabled">--</option>\n~;
1450    foreach my $file ( sort @styles ) {
1451        ( $name, $ext ) = split /\./xsm, $file;
1452        $selected = q{};
1453        if ( $ext eq 'css' ) {
1454            if ( $file eq $cssfile && !$admincs ) {
1455                $selected = q~ selected="selected"~;
1456            }
1457            $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;
1458        }
1459    }
1460
1461    opendir TMPLDIR, "$htmldir/Templates/Admin";
1462    @astyles = readdir TMPLDIR;
1463    closedir TMPLDIR;
1464    $admincss = qq~<option value="" disabled="disabled">--</option>\n~;
1465    foreach my $file ( sort @astyles ) {
1466        ( $name, $ext ) = split /\./xsm, $file;
1467        $selected = q{};
1468        if ( $ext eq 'css' ) {
1469            if ( $file eq $cssfile && $admincs ) {
1470                $selected = q~ selected="selected"~;
1471            }
1472            $admincss .= qq~<option value="$file"$selected>$name</option>\n~;
1473        }
1474    }
1475
1476    fopen( CSS, "$csstype" ) or fatal_error( 'cannot_open', "$csstype" );
1477    while ( $line = <CSS> ) {
1478        $line =~ s/[\r\n]//gxsm;
1479        $line =~ s/&nbsp;/&#38;nbsp;/gsm;
1480        $line =~ s/&amp;/&#38;amp;/gsm;
1481        FromHTML($line);
1482        $fullcss .= qq~$line\n~;
1483    }
1484    fclose(CSS);
1485
1486    $yymain .= qq~
1487<div class="bordercolor rightboxdiv">
1488    <form action="$adminurl?action=modcss;cssfile=$cssfile" name="modcss" method="post" style="display: inline;" accept-charset="$yymycharset">
1489    <table class="border-space pad-cell">
1490        <tr>
1491            <td class="titlebg">
1492                $admin_img{'xx'} <b> $templ_txt{'51'}</b> - $cssfile &nbsp;
1493                <input type="submit" name="wysiwyg" id="wysiwyg" value=" wysiwyg " class="button" />
1494                <input type="button" name="source" id="source" value=" source " disabled="disabled" />
1495            </td>
1496        </tr>
1497    </table>
1498    </form>
1499    <table class="border-space pad-cell" style="margin-bottom:.5em">
1500        <tr>
1501            <td class="windowbg2">
1502                <div style="float: left; width: 30%; padding: 3px;"><b>$templ_txt{'1'}</b></div>
1503                <div style="float: left; width: 69%;">
1504                    <form action="$adminurl?action=modstyle" name="selcss" method="post" style="display: inline;" accept-charset="$yymycharset">
1505                    <div class="small" style="float: left; width: 25%;"><label for="cssfile" style="font-weight:bold">$templ_txt{'forum'}:</label><br />
1506                    <select name="cssfile" id="cssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.aselcss.admcssfile.selectedIndex = '0'; submit(); }">
1507                        $forumcss
1508                    </select>
1509                    <br />
1510                    </div>
1511                    </form>
1512                    <form action="$adminurl?action=modstyle" name="aselcss" method="post" style="display: inline;" accept-charset="$yymycharset">
1513                    <div class="small" style="float: left; width: 25%;"><label for="admcssfile" style="font-weight:bold">$templ_txt{'admincenter'}:</label><br />
1514                    <select name="admcssfile" id="admcssfile" size="1" style="width: 90%;" onchange="if(this.options[this.selectedIndex].value) { document.selcss.cssfile.selectedIndex = '0'; submit(); }">
1515                        $admincss
1516                    </select>
1517                    <br />
1518                    </div>
1519                    </form>
1520                </div>
1521            </td>
1522        </tr>
1523    </table>
1524</div>
1525<div class="bordercolor borderstyle rightboxdiv">
1526    <form action="$adminurl?action=modstyle2" method="post" accept-charset="$yymycharset">
1527    <table class="border-space pad-cell" style="margin-bottom: .5em;">
1528        <tr>
1529            <td class="windowbg2 center">
1530                <input type="hidden" name="filename" value="$cssfile" />
1531                <input type="hidden" name="type" value="$admincs" />
1532                <textarea rows="20" cols="95" name="css" style="width: 99%; height: 350px;; font-family:Courier">$fullcss</textarea>
1533            </td>
1534        </tr>
1535    </table>
1536</div>
1537<div class="bordercolor rightboxdiv">
1538    <table class="border-space pad-cell">
1539        <tr>
1540            <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
1541        </tr><tr>
1542            <td class="catbg center">
1543                <input type="submit" value="$admin_txt{'10'} $cssfile" class="button" />
1544            </td>
1545        </tr>
1546    </table>
1547    </form>
1548</div>
1549
1550~;
1551    $yytitle     = $templ_txt{'1'};
1552    $action_area = 'modcss';
1553    AdminTemplate();
1554    return;
1555}
1556
1557sub ModifyStyle2 {
1558    is_admin_or_gmod();
1559    $FORM{'css'} =~ tr/\r//d;
1560    $FORM{'css'} =~ s/\A\n//xsm;
1561    $FORM{'css'} =~ s/\n\Z//xsm;
1562
1563    if   ( $FORM{'filename'} ) { $cssfile = $FORM{'filename'}; }
1564    else                       { $cssfile = 'default.css'; }
1565    if ( $FORM{'type'} ) {
1566        fopen( CSS, ">$htmldir/Templates/Admin/$cssfile" )
1567          || fatal_error( 'cannot_open', "$htmldir/Templates/Admin/$cssfile", 1 );
1568    }
1569    else {
1570        fopen( CSS, ">$htmldir/Templates/Forum/$cssfile" )
1571          || fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile", 1 );
1572    }
1573    print {CSS} "$FORM{'css'}\n" or croak "$croak{'print'} CSS";
1574    fclose(CSS);
1575    $yySetLocation = qq~$adminurl?action=modcss;cssfile=$cssfile~;
1576    redirectexit();
1577    return;
1578}
1579
1580sub ModifyCSS {
1581    is_admin_or_gmod();
1582
1583    if   ( $INFO{'templateset'} ) { $thistemplate = $INFO{'templateset'}; }
1584    else                          { $thistemplate = "$template"; }
1585
1586    while ( ( $curtemplate, $value ) = each %templateset ) {
1587        if ( $curtemplate eq $thistemplate ) { $akttemplate = $curtemplate; }
1588    }
1589
1590    ( $aktstyle, $aktimages, $akthead, $aktboard, $aktmessage, $aktdisplay, $aktmenutype, $aktthreadtools, $aktposttools ) =
1591      split /\|/xsm, $templateset{$akttemplate};
1592
1593    my ( $fullcss, $line );
1594    if   ( $INFO{'cssfile'} ) { $cssfile = $INFO{'cssfile'}; }
1595    else                      { $cssfile = "$aktstyle.css"; }
1596
1597    $tempimages = qq~$yyhtml_root/Templates/Forum/$aktimages~;
1598    my $istabbed = 0;
1599
1600    $cssbuttons = 0;
1601    $stylestr = q{};
1602
1603    opendir TMPLDIR, "$htmldir/Templates/Forum";
1604    @styles = readdir TMPLDIR;
1605    closedir TMPLDIR;
1606    $forumcss = q{};
1607    $imgdirs  = q{};
1608    foreach my $file ( sort @styles ) {
1609        if ( $file ne 'calscroller.css' && $file ne 'setup.css' ) {
1610        ( $name, $ext ) = split /\./xsm, $file;
1611        $selected = q{};
1612            if ( $ext eq 'css' ) {
1613                if ( $file eq $cssfile ) {
1614                    $selected = q~ selected="selected"~;
1615                    $viewcss  = $name;
1616                }
1617                $forumcss .= qq~<option value="$file"$selected>$name</option>\n~;
1618            }
1619        }
1620    }
1621
1622    fopen( CSS, "$htmldir/Templates/Forum/$cssfile" )
1623      or fatal_error( 'cannot_open', "$htmldir/Templates/Forum/$cssfile" );
1624    @thecss = <CSS>;
1625    fclose(CSS);
1626    foreach my $style_sgl (@thecss) {
1627        $style_sgl =~ s/[\n\r]//gxsm;
1628        $style_sgl =~ s/\A\s*//xsm;
1629        $style_sgl =~ s/\s*\Z//xsm;
1630        $style_sgl =~ s/\t//gsm;
1631        $style_sgl =~ s/^\s+//gsm;
1632        $style_sgl =~ s/\s+$//gsm;
1633        $style_sgl =~ s/\.\/default/$yyhtml_root\/Templates\/Forum\/default/gsm;
1634        $style_sgl =~ s/\.\/$viewcss/$yyhtml_root\/Templates\/Forum\/$viewcss/gsm;
1635        $style_sgl =~ s/\.\.\/\.\.\/Buttons/$yyhtml_root\/Buttons/gsm;
1636        $stylestr .= qq~$style_sgl ~;
1637    }
1638    $stylestr =~ s/\s{2,}/ /gsm;
1639    my (
1640        $selstyl,            $postsstyle,    $seperatorstyle,
1641        $bodycontainerstyle, $bodystyle,     $containerstyle,
1642        $titlestyle,         $titlestyle_a,  $categorystyle,
1643        $categorystyle_a,    $window1style,  $window2style,
1644        $inputstyle,         $textareastyle, $selectstyle,
1645        $quotestyle,         $codestyle,     $editbgstyle,
1646        $highlightstyle,     $gen_fontsize,  $userinfostyle
1647    );
1648
1649    $gen_fontsize =
1650q~              <select name="cssfntsize" id="cssfntsize" style="vertical-align: middle;" onchange="previewFont()">~;
1651    for my $i ( 7 .. 20 ) {
1652        $gen_fontsize .= qq~                <option value="$i">$i</option>~;
1653    }
1654    $gen_fontsize .= q~
1655                </select>~;
1656    $gen_fontface =
1657q~              <select name="cssfntface" id="cssfntface" style="vertical-align: middle;" onchange="previewFontface()">
1658                    <option value="verdana">Verdana</option>
1659                    <option value="helvetica">Helvetica</option>
1660                    <option value="arial">Arial</option>
1661                    <option value="courier">Courier</option>
1662                    <option value="courier new">Courier New</option>
1663                </select>~;
1664    $gen_borderweigth =
1665q~              <select name="borderweigth" id="borderweigth" style="vertical-align: middle;" onchange="previewBorder()">~;
1666    for my $i ( 0 .. 5 ) {
1667        $gen_borderweigth .= qq~<option value="$i">$i</option>~;
1668    }
1669    $gen_borderweigth .= q~
1670                </select>~;
1671    $gen_borderstyle =
1672qq~             <select name="borderstyle" id="borderstyle" style="vertical-align: middle;" onchange="previewBorder()">
1673                    <option value="solid">$templ_txt{'43'}</option>
1674                    <option value="dashed">$templ_txt{'44'}</option>
1675                    <option value="dotted">$templ_txt{'45'}</option>
1676                    <option value="double">$templ_txt{'46'}</option>
1677                    <option value="groove">$templ_txt{'47'}</option>
1678                    <option value="ridge">$templ_txt{'48'}</option>
1679                    <option value="inset">$templ_txt{'49'}</option>
1680                    <option value="outset">$templ_txt{'50'}</option>
1681                </select>~;
1682
1683    if ( $stylestr =~ /body/sm ) {
1684        $bodystyle = $stylestr;
1685        $bodystyle =~ s/.*?(body\s*?\{.+?\}).*/$1/igsm;
1686        $selstyl .=
1687qq~                 <option value="$bodystyle" selected="selected">$templ_txt{'25'}</option>\n~;
1688    }
1689    if ( $stylestr =~ /\#container/sm ) {
1690        $containerstyle = $stylestr;
1691        $containerstyle =~ s/.*?(\#container.*?\{.+?\}).*/$1/igsm;
1692        $selstyl .=
1693          qq~                   <option value='$containerstyle'>$templ_txt{'26'}</option>\n~;
1694    }
1695    if ( $stylestr =~ /\#header/sm ) {
1696        $headerstyle = $stylestr;
1697        $headerstyle =~ s/.*?(\#header.*?\{.+?\}).*/$1/igsm;
1698        $selstyl .=
1699          qq~                   <option value='$headerstyle'>$templ_txt{'26b'}</option>\n~;
1700    }
1701    if ( $stylestr =~ /\#header a/sm ) {
1702        $headerastyle = $stylestr;
1703        $headerastyle =~ s/.*?(\#header a.*?\{.+?\}).*/$1/igsm;
1704        $selstyl .=
1705          qq~                   <option value='$headerastyle'>$templ_txt{'26c'}</option>\n~;
1706    }
1707    if ( $stylestr =~ /\.tabmenu/sm ) {
1708        $istabbed = 1;
1709        $tabmenustyle = $stylestr;
1710        $tabmenustyle =~ s/.*?(\.tabmenu\s*?\{.+?\}).*/$1/igsm;
1711        $selstyl .=
1712          qq~                   <option value='$tabmenustyle'>$templ_txt{'tabmenu'}</option>\n~;
1713    }
1714    if ( $stylestr =~ /\.tabtitle/sm && $istabbed ) {
1715        $tabtitlestyle = $stylestr;
1716        $tabtitlestyle =~ s/.*?(\.tabtitle\s*?\{.+?\}).*/$1/igsm;
1717        $selstyl .=
1718          qq~                   <option value='$tabtitlestyle'>$templ_txt{'tabtitle'}</option>\n~;
1719        if ( $stylestr =~ /\.tabtitle a, .tabtitle-bottom a/ ) {
1720            $tabtitlestyle_a = $stylestr;
1721            $tabtitlestyle_a =~ s/.*?(\.tabtitle a, \.tabtitle-bottom a\s*?\{.+?\}).*/$1/igsm;
1722            $selstyl .=
1723qq~                 <option value='$tabtitlestyle_a'>$templ_txt{'tabtitlea'}</option>\n~;
1724        }
1725    }
1726    if ( $stylestr =~ /\.buttonleft/sm && $stylestr =~ /\.buttonright/sm && $stylestr =~ /\.buttonimage/sm && $stylestr =~ /\.buttontext/sm ) {
1727        $cssbuttons = 1;
1728        $buttonstyle = $stylestr;
1729        $buttonstyle =~ s/.*?(\.buttontext\s*?\{.+?\}).*/$1/igsm;
1730        $selstyl .= qq~<option value='$buttonstyle'>$templ_txt{'buttontext'}</option>\n~;
1731        $prevtext = $buttonstyle;
1732        $prevtext =~ s/\.buttontext\s*?\{(.+?)\}/$1/igsm;
1733        $drawtxtpos = $prevtext;
1734        $drawtxtpos =~ m/.*?top\s*?\:\s*?(\d{1,2})px.*/ism;
1735        $viewtxty = $1;
1736        $viewtxty .= 'px';
1737        $drawpos4 = ($1 * 5) + 213;
1738        $drawpos4 .= 'px';
1739        $buttonleftstyle = $stylestr;
1740        $buttonleftstyle =~ s/.*?(\.buttonleft\s*?\{.+?\}).*/$1/igsm;
1741        $buttonleftbg = qq~<input type="hidden" id="buttonleftbg" name="buttonleftbg" value="$buttonleftstyle" />\n~;
1742        $buttonbg = $buttonleftstyle;
1743        $buttonbg =~ s~.*?($yyhtml_root/Buttons/)(.*?)\.(.*)~$2~gsm;
1744        $prevleft = $buttonleftstyle;
1745        $prevleft =~ s/\.buttonleft\s*?\{(.+?)\}/$1/igsm;
1746        $buttonrightstyle = $stylestr;
1747        $buttonrightstyle =~ s/.*?(\.buttonright\s*?\{.+?\}).*/$1/igsm;
1748        $buttonrightbg = qq~<input type="hidden" id="buttonrightbg" name="buttonrightbg" value="$buttonrightstyle" />\n~;
1749        $prevright = $buttonrightstyle;
1750        $prevright =~ s/\.buttonright\s*?\{(.+?)\}/$1/igsm;
1751        $buttonimagestyle = $stylestr;
1752        $buttonimagestyle =~ s/.*?(\.buttonimage\s*?\{.+?\}).*/$1/igsm;
1753        $buttonimagebg = qq~<input type="hidden" id="buttonimagebg" name="buttonimagebg" value="$buttonimagestyle" />\n~;
1754        $previmage = $buttonimagestyle;
1755        $previmage =~ s/\.buttonimage\s*?\{(.+?)\}/$1/igsm;
1756        $drawimgpos = $previmage;
1757        $drawimgpos =~ m/.*?background\-position\s*?\:\s*?(\d{1,2})px\s*?(\d{1,2})px.*/ism;
1758        $viewimgy = $2;
1759        $viewimgy .= 'px';
1760        $drawpos1 = ($2 * 5) + 213;
1761        $drawpos1 .= 'px';
1762        $viewimgx = $1;
1763        $viewimgx .= 'px';
1764        $drawpos2 = $1 + 213;
1765        $drawpos2 .= 'px';
1766        $drawimgwd = $previmage;
1767        $drawimgwd =~ m/.*?padding\s*?\:\s*?\d{1,2}px\s*?\d{1,2}px\s*?\d{1,2}px\s*?(\d{1,2})px.*/ism;
1768        $viewimgpad = $1;
1769        $viewimgpad .= 'px';
1770        $drawpos3 = $1 + 213;
1771        $drawpos3 .= 'px';
1772    }
1773    if ( $stylestr =~ /\.seperator/sm ) {
1774        $seperatorstyle = $stylestr;
1775        $seperatorstyle =~ s/.*?(\.seperator\s*?\{.+?\}).*/$1/igsm;
1776        $selstyl .=
1777          qq~                   <option value='$seperatorstyle'>$templ_txt{'27'}</option>\n~;
1778    }
1779    if ( $stylestr =~ /\.bordercolor/sm ) {
1780        $bordercolorstyle = $stylestr;
1781        $bordercolorstyle =~ s/.*?(\.bordercolor\s*?\{.+?\}).*/$1/igsm;
1782        $selstyl .=
1783          qq~                   <option value='$bordercolorstyle'>$templ_txt{'28'}</option>\n~;
1784    }
1785    if ( $stylestr =~ /\.hr/sm ) {
1786        $hrstyle = $stylestr;
1787        $hrstyle =~ s/.*?(\.hr\s*?\{.+?\}).*/$1/igsm;
1788        $selstyl .= qq~                 <option value='$hrstyle'>$templ_txt{'29'}</option>\n~;
1789    }
1790    if ( $stylestr =~ /\.titlebg/sm ) {
1791        $titlestyle = $stylestr;
1792        $titlestyle =~ s/.*?(\.titlebg\s*?\{.+?\}).*/$1/igsm;
1793        $titlestyle = $titlestyle;
1794        $selstyl .= qq~                 <option value='$titlestyle'>$templ_txt{'30'}</option>\n~;
1795        if ( $stylestr =~ /\.titlebg a/sm ) {
1796            $titlestyle_a = $stylestr;
1797            $titlestyle_a =~ s/.*?(\.titlebg a\s*?\{.+?\}).*/$1/igsm;
1798            $selstyl .=
1799              qq~                   <option value='$titlestyle_a'>$templ_txt{'30a'}</option>\n~;
1800        }
1801    }
1802    if ( $stylestr =~ /\.catbg/sm ) {
1803        $categorystyle = $stylestr;
1804        $categorystyle =~ s/.*?(\.catbg\s*?\{.+?\}).*/$1/igsm;
1805        $categorystyle = $categorystyle;
1806        $selstyl .=
1807          qq~                   <option value='$categorystyle'>$templ_txt{'31'}</option>\n~;
1808        if ( $stylestr =~ /\.catbg a/sm ) {
1809            $categorystyle_a = $stylestr;
1810            $categorystyle_a =~ s/.*?(\.catbg a\s*?\{.+?\}).*/$1/igsm;
1811            $selstyl .=
1812              qq~                   <option value='$categorystyle_a'>$templ_txt{'31a'}</option>\n~;
1813        }
1814    }
1815    if ( $stylestr =~ /\.windowbg/sm ) {
1816        $window1style = $stylestr;
1817        $window1style =~ s/.*?(\.windowbg\s*?\{.+?\}).*/$1/igsm;
1818        $selstyl .=
1819          qq~                   <option value='$window1style'>$templ_txt{'32'}</option>\n~;
1820    }
1821    if ( $stylestr =~ /\.windowbg2/sm ) {
1822        $window2style = $stylestr;
1823        $window2style =~ s/.*?(\.windowbg2.*?\{.+?\}).*/$1/igsm;
1824        $windowcol2 = $window2style;
1825        $windowcol2 =~ s/.*?(\#[a-f0-9]{3,6}).*/$1/ism;
1826        $selstyl .=
1827          qq~                   <option value='$window2style'>$templ_txt{'33'}</option>\n~;
1828    }
1829    if ( $stylestr =~ /\.post-userinfo/sm ) {
1830        $userinfostyle = $stylestr;
1831        $userinfostyle =~ s/.*?(\.post-userinfo.*?\{.+?\}).*/$1/igsm;
1832        $selstyl .=
1833          qq~                   <option value='$userinfostyle'>$templ_txt{'userinfo'}</option>\n~;
1834    }
1835    if ( $stylestr =~ /\.message/sm ) {
1836        $postsstyle = $stylestr;
1837        $postsstyle =~ s/.*?(\.message\s*?\{.+?\}).*/$1/igsm;
1838        $selstyl .= qq~                 <option value='$postsstyle'>$templ_txt{'65'}</option>\n~;
1839
1840        if ( $stylestr =~ /\.message a/sm ) {
1841            $postsstyle_a = $stylestr;
1842            $postsstyle_a =~ s/.*?(\.message a\s*?\{.+?\}).*/$1/igsm;
1843            $selstyl .=
1844              qq~                   <option value='$postsstyle_a'>$templ_txt{'66'}</option>\n~;
1845        }
1846    }
1847    if ( $stylestr =~ /input/sm ) {
1848        $inputstyle = $stylestr;
1849        $inputstyle =~ s/.*?(input\s*?\{.+?\}).*/$1/igsm;
1850        $selstyl .=
1851          qq~                   <option value='$inputstyle'>$templ_txt{'34a'}</option>\n~;
1852    }
1853    if ( $stylestr =~ /button/sm ) {
1854        $buttonstyle = $stylestr;
1855        $buttonstyle =~ s/.*?(button\s*?\{.+?\}).*/$1/igsm;
1856        $selstyl .=
1857          qq~                   <option value='$buttonstyle'>$templ_txt{'34b'}</option>\n~;
1858    }
1859    if ( $stylestr =~ /textarea/sm ) {
1860        $textareastyle = $stylestr;
1861        $textareastyle =~ s/.*?(textarea\s*?\{.+?\}).*/$1/igsm;
1862        $selstyl .=
1863          qq~                   <option value='$textareastyle'>$templ_txt{'35'}</option>\n~;
1864    }
1865    if ( $stylestr =~ /select/sm ) {
1866        $selectstyle = $stylestr;
1867        $selectstyle =~ s/.*?(select\s*?\{.+?\}).*/$1/igsm;
1868        $selstyl .=
1869          qq~                   <option value='$selectstyle'>$templ_txt{'36'}</option>\n~;
1870    }
1871    if ( $stylestr =~ /.quote/sm ) {
1872        $quotestyle = $stylestr;
1873        $quotestyle =~ s/.*?(\.quote\s*?\{.+?\}).*/$1/igsm;
1874        $selstyl .= qq~                 <option value='$quotestyle'>$templ_txt{'37'}</option>\n~;
1875        $message = qq~\[quote\]$templ_txt{'53'}\[/quote\]~;
1876        if ($enable_ubbc) {
1877            enable_yabbc();
1878            DoUBBC();
1879        }
1880        $aquote = $message;
1881    }
1882    if ( $stylestr =~ /.code/sm ) {
1883        $codestyle = $stylestr;
1884        $codestyle =~ s/.*?(\.code\s*?\{.+?\}).*/$1/igsm;
1885        $selstyl .= qq~                 <option value='$codestyle'>$templ_txt{'38'}</option>\n~;
1886        $message = qq~\[code\]$templ_txt{'54'}\[/code\]~;
1887        if ($enable_ubbc) {
1888            enable_yabbc();
1889            DoUBBC();
1890        }
1891        $acode = $message;
1892    }
1893    if ( $stylestr =~ /.editbg/sm ) {
1894        $editbgstyle = $stylestr;
1895        $editbgstyle =~ s/.*?(\.editbg\s*?\{.+?\}).*/$1/igsm;
1896        $selstyl .=
1897          qq~                   <option value='$editbgstyle'>$templ_txt{'24'}</option>\n~;
1898        $message = qq~\[edit\]$templ_txt{'55'}\[/edit\]~;
1899        if ($enable_ubbc) {
1900            enable_yabbc();
1901            DoUBBC();
1902        }
1903        $aedit = $message;
1904    }
1905    if ( $stylestr =~ /.highlight/sm ) {
1906        $highlightstyle = $stylestr;
1907        $highlightstyle =~ s/.*?(\.highlight\s*?\{.+?\}).*/$1/igsm;
1908        $selstyl .=
1909          qq~                   <option value='$highlightstyle'>$templ_txt{'39'}</option>\n~;
1910        $message = qq~\[highlight\]$templ_txt{'56'}\[/highlight\]~;
1911        if ($enable_ubbc) {
1912            enable_yabbc();
1913            DoUBBC();
1914        }
1915        $ahighlight = $message;
1916    }
1917    if ( $stylestr =~ /\.bodycontainer/sm ) {
1918        $bodycontainerstyle = 1;
1919    }
1920
1921    $yymain .= qq~
1922<form action="$adminurl?action=modstyle" name="modstyles" id="modstyles" method="post" accept-charset="$yymycharset">
1923<div class="bordercolor rightboxdiv">
1924    <table class="border-space pad-cell">
1925        <tr>
1926            <td class="titlebg">
1927                    $admin_img{'xx'} <b>$templ_txt{'51'}</b> - $viewcss &nbsp;
1928                    <input type="hidden" name="cssfile" value="$cssfile" />
1929                    <input type="button" name="wysiwyg" id="wysiwyg" value="wysiwyg" disabled="disabled" />
1930                    <input type="submit" name="source" id="source" value="source" class="button" />
1931            </td>
1932        </tr>
1933    </table>
1934</div>
1935</form>
1936<form action="$adminurl?action=modcss2" name="allstyles" id="allstyles" method="post" accept-charset="$yymycharset">
1937<div class="bordercolor borderstyle rightboxdiv">
1938    <table class="border-space" style="margin-bottom: -1px;">
1939        <tr>
1940            <td class="windowbg2 center">
1941                <iframe id="StyleManager" name="StyleManager" style="border:0" scrolling="yes"></iframe>
1942            </td>
1943        </tr>
1944    </table>
1945    <table class="border-space pad-cell" style="margin-bottom: .5em;">
1946        <tr>
1947            <td class="windowbg2">
1948                <div style="float: left; width: 30%; padding: 3px;"><label for="cssfile"><b>$templ_txt{'1'}</b>$templ_txt{'1b'}</label></div>
1949                <div style="float: left; width: 69%;">
1950                    <input type="hidden" name="button" value="0" />
1951                    <select name="cssfile" id="cssfile" size="1" onchange="document.allstyles.button.value = '1'; submit();">
1952                        $forumcss
1953                    </select>
1954                    <input type="button" value="$templ_txt{'14'}" onclick="document.allstyles.button.value = '3'; if (confirm('$templ_txt{'15'} $cssfile?')) submit();" />
1955                </div>
1956            </td>
1957        </tr><tr>
1958            <td class="windowbg2">
1959                <div style="float: left; width: 30%; padding: 3px;">
1960                    <label for="csselement"><b>$templ_txt{'18'}</b><br /><span class="small">$templ_txt{'19'}<br /><br /></span></label>
1961                </div>
1962                <div style="float: left; width: 69%;">
1963                    <div style="float: left; text-align: center; margin-left: 0; margin-right: 6px; vertical-align: middle;">
1964                        <select name="csselement" id="csselement" size="5" onchange="setElement()">
1965                            $selstyl
1966                        </select>
1967                    </div>
1968                    <div style="float: left;">
1969                        <div class="small" style="float: left; vertical-align: middle;">
1970                            <span style="width: 70px;">
1971                                <input type="radio" name="selopt" id="selopt1" value="color" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt1"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'22'}</b></span></label>
1972                            </span>
1973                            <span>
1974                                <input type="text" size="9" name="textcol" id="textcol" value="$textcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />
1975                                $gen_fontface $gen_fontsize
1976                                <img src="$imagesdir/cssbold.gif" alt="bold" name="cssbold" id="cssbold" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontweight()" />
1977                                <img src="$imagesdir/cssitalic.gif" alt="italic" name="cssitalic" id="cssitalic" style="border: 2px #eeeeee outset; vertical-align: middle;" onclick="previewFontstyle()" />
1978                            </span>
1979                            <br />
1980                            <span style="width: 70px;">
1981                                <input type="radio" name="selopt" id="selopt2" value="background-color" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt2"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'21'}</b></span></label>
1982                            </span>
1983                            <span>
1984                                <input type="text" size="9" name="backcol" id="backcol" value="$backcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewColor(this.value)" />
1985                            </span>
1986                            <br />
1987                            <span style="width: 70px;">
1988                                <input type="radio" name="selopt" id="selopt3" value="border" class="windowbg2" style="border: 0; vertical-align: middle;" onclick="manSelect();" /> <label for="selopt3"><span class="small" style="vertical-align: middle;"><b>$templ_txt{'23'}</b></span></label>
1989                            </span>
1990                            <span>
1991                                <input type="text" size="9" name="bordcol" id="bordcol" value="$bordcol" class="windowbg2" style="font-size: 10px; border: 1px #eef7ff solid; vertical-align: middle;" onchange="previewBorder()" />
1992                                $gen_borderstyle $gen_borderweigth
1993                            </span>
1994                            <br />
1995                        </div>
1996                        <div style="float: left; height: 68px; width: 93px; overflow: auto; border: 0; margin-left: 8px;">
1997                            <div style="float: left; height: 22px; width: 92px;">
1998                                <div class="palettebox" style="width:68px">
1999                                    <span class="deftpal" style="background-color: #000000;" onclick="ConvShowcolor('#000000')">&nbsp;</span>
2000                                    <span class="deftpal" style="background-color: #333333;" onclick="ConvShowcolor('#333333')">&nbsp;</span>
2001                                    <span class="deftpal" style="background-color: #666666;" onclick="ConvShowcolor('#666666')">&nbsp;</span>
2002                                    <span class="deftpal" style="background-color: #999999;" onclick="ConvShowcolor('#999999')">&nbsp;</span>
2003                                    <span class="deftpal" style="background-color: #cccccc;" onclick="ConvShowcolor('#cccccc')">&nbsp;</span>
2004                                    <span class="deftpal" style="background-color: #ffffff;" onclick="ConvShowcolor('#ffffff')">&nbsp;</span>
2005                                    <span class="deftpal" id="defaultpal1" style="background-color: $pallist[0];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2006                                    <span class="deftpal" id="defaultpal2" style="background-color: $pallist[1];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2007                                    <span class="deftpal" id="defaultpal3" style="background-color: $pallist[2];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2008                                    <span class="deftpal" id="defaultpal4" style="background-color: $pallist[3];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2009                                    <span class="deftpal" id="defaultpal5" style="background-color: $pallist[4];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2010                                    <span class="deftpal" id="defaultpal6" style="background-color: $pallist[5];" onclick="ConvShowcolor(this.style.backgroundColor)">&nbsp;</span>
2011                                </div>
2012                                <div style="float:left; height:22px; padding-left: 1px; padding-right: 1px; width:23px; margin-top:-11px">
2013                                    <img src="$admin_images/palette1.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=palette;task=templ', '', 'height=308,width=302,menubar=no,toolbar=no,scrollbars=no')" alt="" />
2014                                </div>
2015                            </div>
2016                        </div>
2017                    </div>
2018                </div>
2019            </td>
2020        </tr>
2021        ~;
2022
2023    $thisbutton = q{};
2024    opendir DIR, "$htmldir/Buttons";
2025    @contents = readdir DIR;
2026    closedir DIR;
2027    $optbuttons = q{};
2028    $x = 1;
2029    foreach my $line (sort @contents){
2030        ($name, $extension) = split /\./xsm, $line;
2031        ($tmpname, $tmpside) = split /\_/xsm, $name;
2032        $checked = q{};
2033        if ($name eq $buttonbg) { $checked = q~ checked = "checked"~; }
2034        if (($extension =~ /gif/ism || $extension =~ /png/ism) && $tmpside eq 'left') {
2035            $bleft = qq~_left.$extension~;
2036            $bright = qq~_right.$extension~;
2037            $thisbutton .= qq~<div style="float: left; width: 99%; margin: 2px; vertical-align: bottom;"><div style="float: left; height: 20px; width: 112px; padding: 0 0 0 6px; background-image: url($yyhtml_root/Buttons/$tmpname$bleft); background-repeat: no-repeat; vertical-align: bottom; cursor: pointer;" onclick="updateButtons('$line');">~;
2038            $thisbutton .= qq~<div style="float: left; height: 20px; padding: 0 80px 0 0; background-image: url($yyhtml_root/Buttons/$tmpname$bright); background-position: right; background-repeat: no-repeat; vertical-align: bottom;"><div style="float: left; height: 20px; padding: 0 0 0 25px;"></div></div></div>~;
2039            $thisbutton .= qq~<div style="float: left; height: 20px;"><input type="radio" name="selbutton" id="selbutton$x" value="$line" class="windowbg2" style="border: 0; vertical-align: middle;"$checked onclick="updateButtons(this.value);" /> <label for="selbutton$x" style="vertical-align: middle;"><b>$tmpname</b></label></div></div>\n~;
2040            $x++;
2041        }
2042    }
2043
2044$yymain .= qq~<tr>
2045        <td align="left" class="windowbg2">
2046        <div style="float: left; width: 99%; padding: 3px;">
2047            <b>$templ_txt{'buttontext'}</b><br /><span class="small">$templ_txt{'buttondescription'}<br /><br /></span>
2048        </div>
2049        <div style="float: left; width: 330px; height: 136px; padding: 3px;">
2050        <div class="catbg" style="position: relative; top: 0; left: 5px; width: 280px; text-align: center; border-width: 1px; border-style: outset; padding: 3px 0;">
2051        <img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />
2052        <span id="butleft" style="height: 20px; border: 0; margin: 1px 1px; background-position: top left; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block; $prevleft">
2053        <span id="butright" style="height: 20px; border: 0; margin: 0; background-position: top right; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block; $prevright">
2054        <span id="butimage" style="$previmage background-image: url($defaultimagesdir/home.gif); height: 20px; border: 0; margin: 0; background-repeat: no-repeat; vertical-align: top; text-decoration: none; font-size: 18px; display: inline-block;">
2055        <span id="buttext" style="height: 20px; border: 0; margin: 0; padding: 0; text-align: left; text-decoration: none; vertical-align: top; white-space: nowrap; display: inline-block; $prevtext">$img_txt{'103'}</span>
2056        </span></span></span>
2057        <img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />
2058        </div>
2059        <div class="catbg" style="position: relative; top: 4px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
2060        <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'moveicon1'}</b>
2061        <input class="catbg" name="viewimgy" id="viewimgy" type="text" value="$viewimgy" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
2062        <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
2063        <img id="knapImg1" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos1; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt=""  />
2064        </div>
2065        <div class="catbg" style="position: relative; top: 8px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
2066        <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'moveicon2'}</b>
2067        <input class="catbg" name="viewimgx" id="viewimgx" type="text" value="$viewimgx" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
2068        <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
2069        <img id="knapImg2" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos2; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
2070        </div>
2071        <div class="catbg" style="position: relative; top: 12px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
2072        <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'iconspace'}</b>
2073        <input class="catbg" name="viewimgpad" id="viewimgpad" type="text" value="$viewimgpad" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
2074        <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
2075        <img id="knapImg3" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos3; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
2076        </div>
2077        <div class="catbg" style="position: relative; top: 16px; left: 5px; width: 280px; height: 18px; border-width: 1px; border-style: outset;">
2078        <span class="small" style="position: absolute; top: 3px; left: 6px;"><b>$templ_txt{'movetext'}</b>
2079        <input class="catbg" name="viewtxty" id="viewtxty" type="text" value="$viewtxty" style="position: absolute; top: 0; left: 165px; text-align: right; width: 30px; margin: 0; padding: 0; border: 0; font-size: 10px; font-weight: bold; display: inline;" readonly="readonly" /></span>
2080        <img src="$defaultimagesdir/knapbagrms02.gif" style="position: absolute; top: 0; left: 209px; z-index: 1; width: 69px; height: 16px;" alt="" />
2081        <img id="knapImg4" src="$defaultimagesdir/knapyellow.gif" class="skyd" style="position: absolute; left: $drawpos4; top: 2px; cursor: pointer; z-index: 2; width: 13px; height: 15px;" alt="" />
2082        </div>
2083        </div>
2084        <div style="float: left; width: 300px; padding: 3px; padding-left: 13px;">
2085            $thisbutton
2086        </div>
2087        $buttonleftbg
2088        $buttonrightbg
2089        $buttonimagebg
2090
2091<script type="text/javascript">
2092
2093var skydobject={
2094x: 0, temp2 : null, targetobj : null, skydNu : 0, delEnh : 0,
2095initialize:function() {
2096    document.onmousedown = this.skydeKnap
2097    document.onmouseup=function(){
2098        if(this.skydNu) updateStyles();
2099        this.skydNu = 0;
2100    }
2101},
2102changeStyle:function(deleEnh, knapId) {
2103    if (knapId == "knapImg1") {
2104        newypos = parseInt(deleEnh/5);
2105        thenewstyle = document.allstyles.stylelink.value;
2106        cssoption = document.allstyles.buttonimagebg.value;
2107        oldxpos=cssoption.replace(/\.*?background\\-position\\s*?\\:\\s*?(\\d{1,2})\.*/i, "\$1");
2108        newcssoption=cssoption.replace(/(background\\-position\\s*?\\:\.*?\\d{1,2}px\\s*?)\\d{1,2}(px\\;)/i, "\$1" + newypos + "\$2");
2109        document.allstyles.buttonimagebg.value = newcssoption;
2110        re=cssoption.replace(/(.*)/, "\$1");
2111        thenewstyle=thenewstyle.replace(re, newcssoption);
2112        document.allstyles.stylelink.value = thenewstyle;
2113        document.getElementById('butimage').style.backgroundPosition = oldxpos+'px '+newypos+'px';
2114        document.getElementById('viewimgy').value = newypos+'px';
2115    }
2116    if (knapId == "knapImg2") {
2117        newxpos = parseInt(deleEnh);
2118        thenewstyle = document.allstyles.stylelink.value;
2119        cssoption = document.allstyles.buttonimagebg.value;
2120        oldypos=cssoption.replace(/\.*?background\\-position\\s*?\\:\\s*?\\d{1,2}px\\s*?(\\d{1,2})\.*/i, "\$1");
2121        newcssoption=cssoption.replace(/(background\\-position\\s*?\\:\.*?)\\d{1,2}(px\\s*?\\d{1,2}px\\;)/i, "\$1" + newxpos + "\$2");
2122        document.allstyles.buttonimagebg.value = newcssoption;
2123        re=cssoption.replace(/(.*)/, "\$1");
2124        thenewstyle=thenewstyle.replace(re, newcssoption);
2125        document.allstyles.stylelink.value = thenewstyle;
2126        document.getElementById('butimage').style.backgroundPosition = newxpos+'px '+oldypos+'px';
2127        document.getElementById('viewimgx').value = newxpos+'px';
2128    }
2129    if (knapId == "knapImg3") {
2130        newimgpad = parseInt(deleEnh);
2131        thenewstyle = document.allstyles.stylelink.value;
2132        cssoption = document.allstyles.buttonimagebg.value;
2133        newcssoption=cssoption.replace(/(padding\\s*?\\:\.*?\\d{1,2}px\\s*?\\d{1,2}px\\s*?\\d{1,2}px\\s*?)\\d{1,2}(px\\;)/i, "\$1" + newimgpad + "\$2");
2134        document.allstyles.buttonimagebg.value = newcssoption;
2135        re=cssoption.replace(/(.*)/, "\$1");
2136        thenewstyle=thenewstyle.replace(re, newcssoption);
2137        document.allstyles.stylelink.value = thenewstyle;
2138        document.getElementById('butimage').style.padding = '0 0 0 '+newimgpad+'px';
2139        document.getElementById('viewimgpad').value = newimgpad+'px';
2140    }
2141    if (knapId == "knapImg4") {
2142        newtxtpad = parseInt(deleEnh/5);
2143        thenewstyle = document.allstyles.stylelink.value;
2144        allstyleslen = document.allstyles.csselement.length;
2145        for (i = 0; i < allstyleslen; i++) {
2146            tmpselelement = document.allstyles.csselement[i].value;
2147            if (tmpselelement.match(/\\.buttontext/)) {
2148                cssoption = document.allstyles.csselement.options[i].value;
2149                newcssoption=cssoption.replace(/(top\\s*?\\:\.*?)\\d{1,2}(px\\s*?\\;)/i, "\$1" + newtxtpad + "\$2");
2150                document.allstyles.csselement.options[i].value = newcssoption;
2151            }
2152        }
2153        re=cssoption.replace(/(.*)/, "\$1");
2154        thenewstyle=thenewstyle.replace(re, newcssoption);
2155        document.allstyles.stylelink.value = thenewstyle;
2156        document.getElementById('buttext').style.top = newtxtpad+'px';
2157        document.getElementById('viewtxty').value = newtxtpad+'px';
2158    }
2159},
2160flytKnap:function(e) {
2161    var evtobj = window.event ? window.event : e
2162    if (this.skydNu == 1) {
2163        glX = parseInt(this.targetobj.style.left)
2164        this.targetobj.style.left = this.temp2 + evtobj.clientX - this.x + "px"
2165        nyX = parseInt(this.temp2 + evtobj.clientX - this.x)
2166        if (nyX > glX) retning = "vn"; else retning = "hj";
2167        if (nyX < 213 && retning == "hj") { this.targetobj.style.left = 213 + "px"; nyX = 213; retning = "vn"; }
2168        if (nyX > 263 && retning == "vn") { this.targetobj.style.left = 263 + "px"; nyX = 263; retning = "hj"; }
2169        delEnh = parseInt(nyX)-213
2170        var knapObj = this.targetobj.id
2171        skydobject.changeStyle(delEnh, knapObj)
2172        return false
2173    }
2174},
2175skydeKnap:function(e) {
2176    var evtobj = window.event ? window.event : e
2177    this.targetobj = window.event ? event.srcElement : e.target
2178    if (this.targetobj.className == "skyd") {
2179        this.skydNu = 1
2180        this.knapObj = this.targetobj
2181        if (isNaN(parseInt(this.targetobj.style.left))) this.targetobj.style.left = 0
2182        this.temp2 = parseInt(this.targetobj.style.left)
2183        this.x = evtobj.clientX
2184        if (evtobj.preventDefault) evtobj.preventDefault()
2185        document.onmousemove = skydobject.flytKnap
2186    }
2187}
2188}
2189
2190skydobject.initialize()
2191</script>
2192        </td>
2193    </tr>~;
2194
2195    $viewstylestart =
2196q~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2197<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{yabb xml_lang}" lang="{yabb xml_lang}">
2198<head>
2199<title>Test Styles</title>
2200<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
2201~;
2202    $viewstyle = q~
2203<body>
2204<div id="maincontainer">
2205~;
2206    if ($containerstyle) {
2207        $viewstyle .= q~
2208<div id="container">
2209~;
2210    }
2211    if ($istabbed) {
2212        $tabsep = q{};
2213        $tabfill = q{};
2214        $tabtime = timeformat( $date, 1 );
2215
2216        $viewstyle .= qq~
2217    <table class="menutop">
2218        <tr>
2219            <td class="small h_23px" style="padding-left:1%">$tabtime</td>
2220            <td class="right vtop"><div class="yabb_searchbox">
2221                <input id="search1" type="text" onblur="txtInFields(this, 'Search')" onfocus="txtInFields(this, 'Search');" style="font-size: 11px;" value="Search" size="16" name="search"><input type="image" style="background-color: transparent; margin-right: 5px; vertical-align: middle;" title="Posts no more than 31 days old" alt="Posts no more than 31 days old" src="$imagesdir/search.png"></div>
2222            </td>
2223        </tr>
2224    </table>
2225    <table id="header" class="pad_4px">
2226        <tr>
2227            <td class="vtop" style="height:50px">Header (#header) <a href="javascript:;">Header Link (#header a)</a></td>
2228        </tr>
2229    </table>
2230    <table>
2231        <tr>
2232            <td id="tabmenu" class="tabmenu">
2233                <span class="selected"><a href="javascript:;">$tabfill$img_txt{'103'}$tabfill</a></span>
2234                $tabsep<span style="cursor:help;"><a href="javascript:;" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>
2235                $tabsep<span><a href="javascript:;">$tabfill$img_txt{'182'}$tabfill</a></span>
2236                $tabsep<span><a href="javascript:;">$tabfill$img_txt{'331'}$tabfill</a></span>
2237                $tabsep<span><a href="javascript:;">$tabfill$img_txt{'mycenter'}$tabfill</a></span>
2238                $tabsep<span><a href="javascript:;">$tabfill$img_txt{'108'}$tabfill</a></span>
2239            </td>
2240        </tr>
2241    </table>
2242~;
2243    }
2244    if ($containerstyle) {
2245        $viewstyle .= qq~
2246  $templ_txt{'64'}
2247<br /><br />
2248~;
2249    }
2250    if ($bodycontainerstyle) {
2251        $viewstyle .= q~<div class="bodycontainer">~;
2252    }
2253    if ($seperatorstyle) {
2254        $viewstyle .= q~<div class="seperator">~;
2255    }
2256    if ($istabbed) {
2257        $viewstyle .= qq~
2258<table style="border-spacing:0" class="bordercolor">
2259    <colgroup>
2260        <col style="width:1%;  height:25px" />
2261        <col style="width:49%;  height:25px" />
2262        <col style="width:50%;  height:25px" />
2263    </colgroup>
2264    <tr>
2265        <td class="tabtitle" colspan="3">
2266            $templ_txt{'tabtitle'} <a href="javascript:;">$templ_txt{'tabtitlea'}</a>
2267        </td>
2268    </tr>
2269</table>
2270<br />
2271~;
2272    }
2273    $viewstyle .= qq~
2274<table class="bordercolor border-space pad-cell">
2275    <colgroup>
2276        <col span="2" style="width: 50%" />
2277    </colgroup>
2278    <tr>
2279        <td id="title" class="titlebg">
2280            $templ_txt{'30'}
2281        </td>
2282        <td id="titlea" class="titlebg">
2283            <a href="javascript:;">$templ_txt{'30a'}</a>
2284        </td>
2285    </tr>
2286</table>
2287~;
2288    if ($seperatorstyle) {
2289        $viewstyle .= q~</div>~;
2290    }
2291    $viewstyle .= q~
2292<br />
2293~;
2294    if ($seperatorstyle) {
2295        $viewstyle .= q~<div class="seperator">~;
2296    }
2297    $viewstyle .= qq~
2298<table class="bordercolor border-space pad-cell">
2299    <colgroup>
2300        <col span="2" style="width: 50%" />
2301    </colgroup>
2302    <tr>
2303        <td id="category" class="catbg">
2304            $templ_txt{'31'}
2305        </td>
2306        <td id="categorya" class="catbg">
2307            <a href="javascript:;">$templ_txt{'31a'}</a>
2308        </td>
2309    </tr>
2310</table>
2311~;
2312
2313$menusep = qq~<img src="$defaultimagesdir/buttonsep.png" style="height: 20px; width: 1px; margin: 0; padding: 0; vertical-align: top; display: inline-block;" alt="" />~;
2314$viewstyleleft = q~style="height: 20px; border: 0; margin: 1px 1px; background-position: top left; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block;"~;
2315$viewstyleright = q~style="height: 20px; border: 0; margin: 0; background-position: top right; background-repeat: no-repeat; text-decoration: none; font-size: 18px; vertical-align: top; display: inline-block;"~;
2316$viewstyleimage = q~height: 20px; border: 0; margin: 0; background-repeat: no-repeat; vertical-align: top; text-decoration: none; font-size: 18px; display: inline-block;~;
2317$viewstyletext = q~style="height: 20px; border: 0; margin: 0; padding: 0; text-align: left; text-decoration: none; vertical-align: top; white-space: nowrap; display: inline-block;"~;
2318
2319$viewstyle .= qq~
2320<table class="bordercolor border-space pad-cell">
2321    <tr>
2322        <td id="cssbuttons" class="windowbg2 vtop">
2323            <div style="float: left; padding: 4px 0 0 0;">$templ_txt{'buttontext'}</div>
2324            <div style="float: right;">
2325                <a href="javascript:;"><span id="button1l" class="buttonleft" $viewstyleleft title="$img_txt{'145'}"><span id="button1r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/maq1.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'145'}</span></span></span></span></a>$menusep
2326                <a href="javascript:;"><span id="button2l" class="buttonleft" $viewstyleleft title="$img_txt{'66'}"><span id="button2r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/modify.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'66'}</span></span></span></span></a>$menusep
2327                <a href="javascript:;"><span id="button3l" class="buttonleft" $viewstyleleft title="$img_txt{'620'}"><span id="button3r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/admin_split.png); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'620'}</span></span></span></span></a>$menusep
2328                <a href="javascript:;"><span id="button4l" class="buttonleft" $viewstyleleft title="$img_txt{'121'}"><span id="button4r" class="buttonright" $viewstyleright><span class="buttonimage" style="background-image: url($defaultimagesdir/delete.gif); $viewstyleimage"><span class="buttontext" $viewstyletext>$img_txt{'121'}</span></span></span></span></a>
2329            </div>
2330        </td>
2331    </tr>
2332</table>
2333~;
2334
2335$viewstyle .= qq~
2336<table class="bordercolor border-space pad-cell">
2337    <tr>
2338        <td id="window1" class="windowbg vtop">
2339            $templ_txt{'32'}
2340        </td>
2341        <td id="window2" class="windowbg2 vtop">
2342            $templ_txt{'33'}<br />
2343            <hr class="hr">
2344            <div id="messages" class="message">$templ_txt{'65'}</div>
2345            <div id="messagesa" class="message"><a href="javascript:;">$templ_txt{'66'}</a><br /><br /></div>
2346            <textarea rows="4" cols="19">$templ_txt{'35'}</textarea><br />
2347            <input type="text" size="19" value="$templ_txt{'34a'}" />&nbsp;
2348            <select value="test">
2349                <option>$templ_txt{'36'} $templ_txt{'61'}</option>
2350                <option>$templ_txt{'36'} 2</option>
2351            </select>&nbsp;
2352            <input type="button" value="$templ_txt{'34b'}" class="button" />
2353        </td>
2354    </tr><tr>
2355        <td id="window3" class="post-userinfo vtop">$templ_txt{'userinfo'} (.post-userinfo)</td>
2356        <td id="window4" class="windowbg2 vtop">
2357            $aquote
2358            $acode
2359            $aedit<br />
2360            $ahighlight
2361        </td>
2362    </tr>
2363</table>
2364~;
2365    if ($seperatorstyle) {
2366        $viewstyle .= q~</div>~;
2367    }
2368    if ($bodycontainerstyle) {
2369        $viewstyle .= q~</div>~;
2370    }
2371    if ($istabbed) {
2372        $viewstyle .= q~
2373    <br />
2374    <div class="mainbottom">
2375        <table>
2376            <tr>
2377                <td class="nav" style="height:22px">&nbsp;</td>
2378            </tr>
2379        </table>
2380    </div>
2381~;
2382    }
2383    if ($containerstyle) {
2384        $viewstyle .= q~</div>~;
2385    }
2386    $viewstyle .= q~
2387<br /><br />
2388</div>
2389</body>
2390</html>~;
2391    $viewstylestart =~ s/^\s+//gsm;
2392    $viewstylestart =~ s/\s+$//gsm;
2393    $viewstylestart =~ s/[\n\r]//gxsm;
2394    $viewstylestart =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
2395    ToHTML($viewstylestart);
2396    $stylestr =~ s/^\s+//gsm;
2397    $stylestr =~ s/\s+$//gsm;
2398    $stylestr =~ s/[\n\r]//gxsm;
2399    $stylestr =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
2400    ToHTML($stylestr);
2401    $viewstyle =~ s/^\s+//gsm;
2402    $viewstyle =~ s/\s+$//gsm;
2403    $viewstyle =~ s/[\n\r]//gxsm;
2404    $viewstyle =~ s/({|<)yabb xml_lang(}|>)/$abbr_lang/gsm;
2405    ToHTML($viewstyle);
2406
2407    if($viewcss eq 'default') {
2408        $savecss = q{};
2409    }
2410    else {
2411        $savecss = $viewcss;
2412    }
2413
2414    $yymain .= qq~
2415    </table>
2416</div>
2417<div class="bordercolor rightboxdiv">
2418<table class="border-space pad-cell">
2419    <tr>
2420        <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
2421    </tr><tr>
2422        <td class="catbg center">
2423            <input type="hidden" name="stylestart" value="$viewstylestart" />
2424            <input type="hidden" name="stylelink" value="$stylestr" />
2425            <input type="hidden" name="stylebody" value="$viewstyle" />
2426            <label for="savecssas"><b>$templ_txt{'12'}</b></label>
2427            <input type="text" name="savecssas" id="savecssas" value="~
2428            . ( split /\./xsm, $cssfile )[0] . qq~" size="30" maxlength="30" />
2429            <input type="submit" value="$templ_txt{'13'}" onclick="document.allstyles.button.value = '2';" class="button" />
2430            <div class="small" style="font-weight: normal;">$templ_txt{'noedit'}</div>
2431        </td>
2432    </tr>
2433</table>
2434</div>
2435</form>
2436<script type="text/javascript">
2437var cssbold;
2438var cssitalic;
2439var stylesurl = '$yyhtml_root/Templates/Forum';
2440
2441function initStyles() {
2442        var thestylestart = document.allstyles.stylestart.value;
2443        var thestyles = document.allstyles.stylelink.value;
2444        var thestylebody = document.allstyles.stylebody.value;
2445        var thestyle = thestylestart + '\\<style type="text/css"\\>\\<\\!\\-\\-' + thestyles + '\\-\\-\\>\\<\\/style\\>' + thestylebody;
2446        thestyle=thestyle.replace(/\\&quot\\;/g, '"');
2447        thestyle=thestyle.replace(/\\&nbsp\\;/g, " ");
2448        thestyle=thestyle.replace(/\\&\\#124\\;/g, "|");
2449        thestyle=thestyle.replace(/\\&lt\\;/g, "<");
2450        thestyle=thestyle.replace(/\\&gt\\;/g, ">");
2451        thestyle=thestyle.replace(/\\&amp\\;/g, "&");
2452        thestyle=thestyle.replace(/(url\\(\\")(.*?\\/.*?\\"\\))/gi, "\$1" + stylesurl + "\/\$2");
2453        StyleManager.document.open("text/html");
2454        StyleManager.document.write(thestyle);
2455        StyleManager.document.close();
2456}
2457
2458function updateStyles() {
2459        var currentTop = document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop;
2460        initStyles();
2461        document.getElementById('StyleManager').contentWindow.document.documentElement.scrollTop = currentTop;
2462}
2463var buttonurl = '$yyhtml_root/Buttons/';
2464
2465function updateButtons(thebg) {
2466    len = document.allstyles.selbutton.length;
2467    for (i = 0; i <len; i++) {
2468        document.allstyles.selbutton[i].checked = false;
2469        if (document.allstyles.selbutton[i].value == thebg) document.allstyles.selbutton[i].checked = true;
2470    }
2471    thenewstyle = document.allstyles.stylelink.value;
2472    cssoption = document.allstyles.buttonleftbg.value;
2473    newcssoption=cssoption.replace(/(background\\-image\\s*?\\:\.*?\\/Buttons\\/).*?(\\)\\;)/i, "\$1" + thebg + "\$2");
2474    document.getElementById('butleft').style.backgroundImage = 'url(' + buttonurl + thebg + ')';
2475    document.allstyles.buttonleftbg.value = newcssoption;
2476    re=cssoption.replace(/(.*)/, "\$1");
2477    thenewstyle=thenewstyle.replace(re, newcssoption);
2478    document.allstyles.stylelink.value = thenewstyle;
2479    updateStyles();
2480    btside = '_right';
2481    cssoption = document.allstyles.buttonrightbg.value;
2482    newthebg = thebg.replace(/(.*?)\\_left(.*)/i, "\$1" + btside + "\$2");
2483    newcssoption=cssoption.replace(/(background\\-image\\s*?\\:\.*?\\/Buttons\\/).*?(\\)\\;)/i, "\$1" + newthebg + "\$2");
2484    document.getElementById('butright').style.backgroundImage = 'url(' + buttonurl + newthebg + ')';
2485    document.allstyles.buttonrightbg.value = newcssoption;
2486    re=cssoption.replace(/(.*)/, "\$1");
2487    thenewstyle=thenewstyle.replace(re, newcssoption);
2488    document.allstyles.stylelink.value = thenewstyle;
2489    updateStyles();
2490}
2491
2492function previewColor(thecolor) {
2493    thenewstyle = document.allstyles.stylelink.value;
2494    cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2495    var cssfont = document.allstyles.selopt1;
2496    var cssback = document.allstyles.selopt2;
2497    var cssborder = document.allstyles.selopt3;
2498    if(cssfont.checked) {
2499        newcssoption=cssoption.replace(/( color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2");
2500        document.allstyles.textcol.value = thecolor;
2501        if(cssoption.match(/\\#container\\s*?\\{/)) {
2502            thenewstyle=thenewstyle.replace(/(\\.tabmenu span a\\s*?\\{.*?color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
2503        }
2504        if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.color = thecolor;
2505    }
2506    if(cssback.checked) {
2507        newcssoption=cssoption.replace(/(background-color\\s*?\\:).+?(\\;)/i, "\$1 " + thecolor + "\$2");
2508        document.allstyles.backcol.value = thecolor;
2509        if(cssoption.match(/\\.tabmenu\\s*?\\{/)) {
2510            thenewstyle=thenewstyle.replace(/(\\.tabmenu.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
2511            thenewstyle=thenewstyle.replace(/(\\.rightbox.*?\\{.*?background-color\\s*?\\:).+?(\\;)/ig, "\$1 " + thecolor + "\$2");
2512        }
2513    }
2514    if(cssborder.checked) {
2515        tempnewcolor=cssoption;
2516        if(tempnewcolor.match(/border\\s*?\\:/)) {
2517            bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
2518            if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
2519                tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");
2520                viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1");
2521            }
2522        }
2523        if(tempnewcolor.match(/border\\-top\\s*?\\:/)) {
2524            bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");
2525            if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
2526                tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");
2527                viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1");
2528            }
2529        }
2530        if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) {
2531            borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");
2532            if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
2533                tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");
2534                viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1");
2535            }
2536        }
2537        if(tempnewcolor.match(/border\\-left\\s*?\\:/)) {
2538            borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");
2539            if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
2540                tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");
2541                viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1");
2542            }
2543        }
2544        if(tempnewcolor.match(/border\\-right\\s*?\\:/)) {
2545            borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");
2546            if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
2547                tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:.*?)\\#[0-9a-f]{3,6}(.*?\\;)/i, "\$1 " + thecolor + "\$2");
2548                viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1");
2549            }
2550        }
2551        newcssoption=tempnewcolor;
2552        nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2");
2553        theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2");
2554        thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");
2555        document.allstyles.bordcol.value = thecolor;
2556    }
2557    document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2558    re=cssoption.replace(/(.*)/, "\$1");
2559    thenewstyle=thenewstyle.replace(re, newcssoption);
2560    document.allstyles.stylelink.value = thenewstyle;
2561    updateStyles();
2562}
2563
2564function previewBorder() {
2565        thenewstyle = document.allstyles.stylelink.value;
2566        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2567        var cssborder = document.allstyles.selopt3;
2568        var thebweigth = document.allstyles.borderweigth.value;
2569        var thebcolor = document.allstyles.bordcol.value;
2570        var thebstyle = document.allstyles.borderstyle.value;
2571        var thecolor = thebweigth + 'px ' + thebcolor + ' ' + thebstyle;
2572        if(cssborder.checked) {
2573                tempnewcolor=cssoption;
2574                if(tempnewcolor.match(/border\\s*?\\:/)) {
2575                        bordercol=tempnewcolor.replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
2576                        if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
2577                                tempnewcolor=tempnewcolor.replace(/(border\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
2578                                viewnewcolor=tempnewcolor.replace(/.*?border\\s*?\\:(.*?)\\;.*/i, "\$1");
2579                        }
2580                }
2581                if(tempnewcolor.match(/border\\-top\\s*?\\:/)) {
2582                        bordertopcol=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");
2583                        if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
2584                                tempnewcolor=tempnewcolor.replace(/(border\\-top\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
2585                                viewnewcolor=tempnewcolor.replace(/.*?border\\-top\\s*?\\:(.*?)\\;.*/i, "\$1");
2586                        }
2587                }
2588                if(tempnewcolor.match(/border\\-bottom\\s*?\\:/)) {
2589                        borderbottomcol=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");
2590                        if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
2591                                tempnewcolor=tempnewcolor.replace(/(border\\-bottom\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
2592                                viewnewcolor=tempnewcolor.replace(/.*?border\\-bottom\\s*?\\:(.*?)\\;.*/i, "\$1");
2593                        }
2594                }
2595                if(tempnewcolor.match(/border\\-left\\s*?\\:/)) {
2596                        borderleftcol=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");
2597                        if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
2598                                tempnewcolor=tempnewcolor.replace(/(border\\-left\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
2599                                viewnewcolor=tempnewcolor.replace(/.*?border\\-left\\s*?\\:(.*?)\\;.*/i, "\$1");
2600                        }
2601                }
2602                if(tempnewcolor.match(/border\\-right\\s*?\\:/)) {
2603                        borderrightcol=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");
2604                        if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
2605                                tempnewcolor=tempnewcolor.replace(/(border\\-right\\s*?\\:).*?\\#[0-9a-f]{3,6}.*?(\\;)/i, "\$1 " + thecolor + "\$2");
2606                                viewnewcolor=tempnewcolor.replace(/.*?border\\-right\\s*?\\:(.*?)\\;.*/i, "\$1");
2607                        }
2608                }
2609                newcssoption=tempnewcolor;
2610
2611                nocolor=viewnewcolor.replace(/(.*?)\\#[0-9a-f]{3,6}(.*)/i, "\$1\$2");
2612                theborderstyle=viewnewcolor.replace(/(.*?)(solid|dashed|dotted|double|groove|ridge|inset|outset)(.*)/i, "\$2");
2613                thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");
2614                document.allstyles.bordcol.value = thebcolor;
2615        }
2616        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2617        re=cssoption.replace(/(.*)/, "\$1");
2618        thenewstyle=thenewstyle.replace(re, newcssoption);
2619        document.allstyles.stylelink.value = thenewstyle;
2620        updateStyles();
2621}
2622
2623function previewFont() {
2624        thesize = document.allstyles.cssfntsize.options[document.allstyles.cssfntsize.selectedIndex].value;
2625        thenewstyle = document.allstyles.stylelink.value;
2626        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2627        newcssoption=cssoption.replace(/(font\\-size\\s*?\\:\\s*?)[\\d]{1,2}(\\w+?\;)/i, "\$1" + thesize + "\$2");
2628        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2629        re=cssoption.replace(/(.*)/, "\$1");
2630        thenewstyle=thenewstyle.replace(re, newcssoption);
2631        document.allstyles.stylelink.value = thenewstyle;
2632        if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontSize = thesize;
2633        updateStyles();
2634}
2635
2636function previewFontface() {
2637        theface = document.allstyles.cssfntface.options[document.allstyles.cssfntface.selectedIndex].value;
2638        thenewstyle = document.allstyles.stylelink.value;
2639        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2640        thetmpfontface=cssoption.replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*?\\}/i, "\$1");
2641        thearrfontface=thetmpfontface.split(",");
2642        optnumb=thearrfontface.length;
2643        newfontarr = theface;
2644        for(i = 0; i < optnumb; i++) {
2645                thefontface = thearrfontface[i].toLowerCase();
2646                thefontface=thefontface.replace(/^\\s/g, "");
2647                thefontface=thefontface.replace(/\\s\$/g, "");
2648                if(thefontface != theface) newfontarr += ', ' + thefontface;
2649        }
2650        newcssoption=cssoption.replace(/(font\\-family\\s*?\\:).*?(\;)/i, "\$1 " + newfontarr + "\$2");
2651        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2652        re=cssoption.replace(/(.*)/, "\$1");
2653        thenewstyle=thenewstyle.replace(re, newcssoption);
2654        document.allstyles.stylelink.value = thenewstyle;
2655        if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontFamily = theface;
2656        updateStyles();
2657}
2658
2659function previewFontweight() {
2660        if(cssbold == false) return;
2661        thenewstyle = document.allstyles.stylelink.value;
2662        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2663        thetmpfontweight=cssoption.replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
2664        thetmpfontweight=thetmpfontweight.replace(/\\s/g, "");
2665        if(thetmpfontweight == 'normal') {
2666                thefontweight = 'bold';
2667                document.getElementById('cssbold').style.borderStyle = 'inset';
2668        }
2669        else {
2670                thefontweight = 'normal';
2671                document.getElementById('cssbold').style.borderStyle = 'outset';
2672        }
2673        newcssoption=cssoption.replace(/(font\\-weight\\s*?\\:).*?(\;)/ig, "\$1 " + thefontweight + "\$2");
2674        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2675        re=cssoption.replace(/(.*)/, "\$1");
2676        thenewstyle=thenewstyle.replace(re, newcssoption);
2677        document.allstyles.stylelink.value = thenewstyle;
2678        if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontWeight = thefontweight;
2679        updateStyles();
2680}
2681
2682function previewFontstyle() {
2683        if(cssitalic == false) return;
2684        thenewstyle = document.allstyles.stylelink.value;
2685        cssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2686        thetmpfontstyle=cssoption.replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
2687        thetmpfontstyle=thetmpfontstyle.replace(/\\s/g, "");
2688        if(thetmpfontstyle == 'normal') {
2689                thefontstyle = 'italic';
2690                document.getElementById('cssitalic').style.borderStyle = 'inset';
2691        }
2692        else {
2693                thefontstyle = 'normal';
2694                document.getElementById('cssitalic').style.borderStyle = 'outset';
2695        }
2696        newcssoption=cssoption.replace(/(font\\-style\\s*?\\:).*?(\;)/ig, "\$1 " + thefontstyle + "\$2");
2697        document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value = newcssoption;
2698        re=cssoption.replace(/(.*)/, "\$1");
2699        thenewstyle=thenewstyle.replace(re, newcssoption);
2700        document.allstyles.stylelink.value = thenewstyle;
2701        if(cssoption.match(/\\.buttontext/)) document.getElementById('buttext').style.fontStyle = thefontstyle;
2702        updateStyles();
2703}
2704
2705function manSelect() {
2706        var cssfont = document.allstyles.selopt1;
2707        var cssback = document.allstyles.selopt2;
2708        var cssborder = document.allstyles.selopt3;
2709        document.allstyles.textcol.disabled = true;
2710        document.allstyles.backcol.disabled = true;
2711        document.allstyles.bordcol.disabled = true;
2712        document.allstyles.borderweigth.disabled = true;
2713        document.allstyles.borderstyle.disabled = true;
2714        if(cssfont.checked == true) {
2715                document.allstyles.textcol.disabled = false;
2716        }
2717        if(cssback.checked == true) {
2718                document.allstyles.backcol.disabled = false;
2719        }
2720        if(cssborder.checked == true) {
2721                document.allstyles.bordcol.disabled = false;
2722                document.allstyles.borderweigth.disabled = false;
2723                document.allstyles.borderstyle.disabled = false;
2724        }
2725}
2726
2727function setElement() {
2728        cssbold = false;
2729        cssitalic = false;
2730
2731        tempcssoption = document.allstyles.csselement.options[document.allstyles.csselement.selectedIndex].value;
2732        tmpcssoption = tempcssoption.split("{");
2733
2734        document.modstyles.wysiwyg.disabled = true;
2735
2736        document.allstyles.cssfntsize.disabled = true;
2737        document.allstyles.cssfntface.disabled = true;
2738        document.getElementById('cssbold').style.backgroundColor = '#cccccc';
2739        document.getElementById('cssbold').style.borderStyle = 'outset';
2740        document.getElementById('cssitalic').style.backgroundColor = '#cccccc';
2741        document.getElementById('cssitalic').style.borderStyle = 'outset';
2742
2743        var cssfont = document.allstyles.selopt1;
2744        var cssback = document.allstyles.selopt2;
2745        var cssborder = document.allstyles.selopt3;
2746        cssfont.checked = false;
2747        cssback.checked = false;
2748        cssborder.checked = false;
2749        cssfont.disabled = true;
2750        cssback.disabled = true;
2751        cssborder.disabled = true;
2752
2753        if(tmpcssoption[1].match(/font\-size/g)) {
2754                cssfont.disabled = false;
2755                document.allstyles.cssfntsize.disabled = false;
2756                thefontsize=tmpcssoption[1].replace(/.*?font\\-size\\s*?\\:\\s*?([\\d]{1,2})\\w+?\\;.*/, "\$1");
2757                if(!thefontsize) thesel=0;
2758                else thesel=thefontsize-7;
2759                document.allstyles.cssfntsize.value = document.allstyles.cssfntsize.options[thesel].value;
2760        }
2761        if(tmpcssoption[1].match(/font\-family/g)) {
2762                cssfont.disabled = false;
2763                document.allstyles.cssfntface.disabled = false;
2764                optnumb=document.allstyles.cssfntface.options.length;
2765                thetmpfontface=tmpcssoption[1].replace(/.*?font\\-family\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
2766                thearrfontface=thetmpfontface.split(",", 1);
2767                thefontface = thearrfontface[0].toLowerCase();
2768                thefontface=thefontface.replace(/^\\s/g, "");
2769                thefontface=thefontface.replace(/\\s\$/g, "");
2770                for(i = 0; i < optnumb; i++) {
2771                        selfontface = document.allstyles.cssfntface.options[i].value;
2772                        if(selfontface == thefontface) document.allstyles.cssfntface.value = selfontface;
2773                }
2774        }
2775
2776        if(tmpcssoption[1].match(/font\-weight/g)) {
2777                cssbold = true;
2778                document.getElementById('cssbold').style.backgroundColor = '#ffffff';
2779                thetmpfontweight=tmpcssoption[1].replace(/.*?font\\-weight\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
2780                if(thetmpfontweight.match(/bold/)) document.getElementById('cssbold').style.borderStyle = 'inset';
2781        }
2782
2783        if(tmpcssoption[1].match(/font\-style/g)) {
2784                cssitalic = true;
2785                document.getElementById('cssitalic').style.backgroundColor = '#ffffff';
2786                thetmpfontstyle=tmpcssoption[1].replace(/.*?font\\-style\\s*?\\:\\s*?([\\D]+?)\\;.*/i, "\$1");
2787                if(thetmpfontstyle.match(/italic/)) document.getElementById('cssitalic').style.borderStyle = 'inset';
2788        }
2789
2790        if(tmpcssoption[1].match(/background\-color/g)) {
2791                cssback.disabled = false;
2792                thebackcolor=tmpcssoption[1].replace(/(.*?)background\\-color\\s*?\\:(.+?)\\;(.*)/i, "\$2");
2793                thebackcolor=thebackcolor.replace(/\\s/g, "");
2794                document.allstyles.backcol.value = thebackcolor;
2795        }
2796        else {
2797                document.allstyles.backcol.value = '';
2798        }
2799        if(tmpcssoption[1].match(/ color/g)) {
2800                cssfont.disabled = false;
2801                thefontcolor=tmpcssoption[1].replace(/(.*?) color\\s*?\\:(.+?)\\;(.*)/i, "\$2");
2802                thefontcolor=thefontcolor.replace(/\\s/g, "");
2803                document.allstyles.textcol.value = thefontcolor;
2804        }
2805        else {
2806                document.allstyles.textcol.value = '';
2807        }
2808
2809        if(tmpcssoption[1].match(/border/)) {
2810                cssborder.disabled = false;
2811                document.allstyles.borderweigth.disabled = false;
2812                document.allstyles.borderstyle.disabled = false;
2813        }
2814        else {
2815                document.allstyles.borderweigth.disabled = true;
2816                document.allstyles.borderstyle.disabled = true;
2817        }
2818        viewnewcolor = '';
2819
2820        if(tmpcssoption[1].match(/border\\s*?\\:/)) {
2821                bordercol=tmpcssoption[1].replace(/.*?border\\s*?\\:(.+?)\\;.*/, "\$1");
2822                if(bordercol.match(/\\#[0-9a-f]{3,6}/i)) {
2823                        viewnewcolor=bordercol;
2824                }
2825        }
2826        if(tmpcssoption[1].match(/border\\-top\\s*?\\:/)) {
2827                bordertopcol=tmpcssoption[1].replace(/.*?border\\-top\\s*?\\:(.+?)\\;.*/, "\$1");
2828                if(bordertopcol.match(/\\#[0-9a-f]{3,6}/i)) {
2829                        viewnewcolor=bordertopcol;
2830                }
2831        }
2832        if(tmpcssoption[1].match(/border\\-bottom\\s*?\\:/)) {
2833                borderbottomcol=tmpcssoption[1].replace(/.*?border\\-bottom\\s*?\\:(.+?)\\;.*/, "\$1");
2834                if(borderbottomcol.match(/\\#[0-9a-f]{3,6}/i)) {
2835                        viewnewcolor=borderbottomcol;
2836                }
2837        }
2838        if(tmpcssoption[1].match(/border\\-left\\s*?\\:/)) {
2839                borderleftcol=tmpcssoption[1].replace(/.*?border\\-left\\s*?\\:(.+?)\\;.*/, "\$1");
2840                if(borderleftcol.match(/\\#[0-9a-f]{3,6}/i)) {
2841                        viewnewcolor=borderleftcol;
2842                }
2843        }
2844        if(tmpcssoption[1].match(/border\\-right\\s*?\\:/)) {
2845                borderrightcol=tmpcssoption[1].replace(/.*?border\\-right\\s*?\\:(.+?)\\;.*/, "\$1");
2846                if(borderrightcol.match(/\\#[0-9a-f]{3,6}/i)) {
2847                        viewnewcolor=borderrightcol;
2848                }
2849        }
2850        thebordercolor=viewnewcolor.replace(/.*?(\\#[0-9a-f]{3,6}).*/i, "\$1");
2851        nocolor=viewnewcolor.replace(/(.*?)(\\#[0-9a-f]{3,6})(.*)/i, "\$1\$3");
2852        optnumb=document.allstyles.borderstyle.options.length;
2853        theborderstyle=viewnewcolor.replace(/.*?(solid|dashed|dotted|double|groove|ridge|inset|outset).*/i, "\$1");
2854        theborderstyle = theborderstyle.toLowerCase();
2855        theborderstyle=theborderstyle.replace(/^\\s/g, "");
2856        theborderstyle=theborderstyle.replace(/\\s\$/g, "");
2857        for(i = 0; i < optnumb; i++) {
2858                selborderstyle = document.allstyles.borderstyle.options[i].value;
2859                if(selborderstyle == theborderstyle) document.allstyles.borderstyle.value = selborderstyle;
2860        }
2861
2862        thebordersize=nocolor.replace(/.*?([\\d]{1,2}).*/i, "\$1");
2863        if(!thebordersize) thebordersize=0;
2864        document.allstyles.bordcol.value = thebordercolor;
2865        document.allstyles.borderweigth.value = document.allstyles.borderweigth.options[thebordersize].value;
2866
2867        if (cssfont.disabled == false) {
2868                cssfont.checked = true;
2869        }
2870        else if (cssback.disabled == false) {
2871                cssback.checked = true;
2872        }
2873        else if (cssborder.disabled == false) {
2874                cssborder.checked = true;
2875        }
2876        manSelect();
2877}
2878
2879initStyles();
2880setElement();
2881
2882// Palette
2883var thistask = 'templ';
2884function tohex(i) {
2885        a2 = ''
2886        ihex = hexQuot(i);
2887        idiff = eval(i + '-(' + ihex + '*16)')
2888        a2 = itohex(idiff) + a2;
2889        while( ihex >= 16) {
2890                itmp = hexQuot(ihex);
2891                idiff = eval(ihex + '-(' + itmp + '*16)');
2892                a2 = itohex(idiff) + a2;
2893                ihex = itmp;
2894        }
2895        a1 = itohex(ihex);
2896        return a1 + a2 ;
2897}
2898
2899function hexQuot(i) {
2900        return Math.floor(eval(i +'/16'));
2901}
2902
2903function itohex(i) {
2904        if( i === 0) { aa = '0' }
2905        else { if( i == 1 ) { aa = '1' }
2906        else { if( i == 2 ) { aa = '2' }
2907        else { if( i == 3 ) { aa = '3' }
2908        else { if( i == 4 ) { aa = '4' }
2909        else { if( i == 5 ) { aa = '5' }
2910        else { if( i == 6 ) { aa = '6' }
2911        else { if( i == 7 ) { aa = '7' }
2912        else { if( i == 8 ) { aa = '8' }
2913        else { if( i == 9 ) { aa = '9' }
2914        else { if( i == 10) { aa = 'a' }
2915        else { if( i == 11) { aa = 'b' }
2916        else { if( i == 12) { aa = 'c' }
2917        else { if( i == 13) { aa = 'd' }
2918        else { if( i == 14) { aa = 'e' }
2919        else { if( i == 15) { aa = 'f' }
2920        }}}}}}}}}}}}}}}
2921        return aa;
2922}
2923
2924function ConvShowcolor(color) {
2925        if ( c=color.match(/rgb\\((\\d+?)\\, (\\d+?)\\, (\\d+?)\\)/i) ) {
2926                var rhex = tohex(c[1]);
2927                var ghex = tohex(c[2]);
2928                var bhex = tohex(c[3]);
2929                var newcolor = '#'+rhex+ghex+bhex;
2930        }
2931        else {
2932                var newcolor = color;
2933        }
2934        if(thistask == "post") showcolor(newcolor);
2935        if(thistask == "templ") previewColor(newcolor);
2936}
2937</script>
2938~;
2939    $yytitle     = $templ_txt{'1'};
2940    $action_area = 'modcss';
2941    AdminTemplate();
2942    return;
2943}
2944
2945sub ModifyCSS2 {
2946    is_admin_or_gmod();
2947    if ( $FORM{'button'} == 1 ) {
2948        $yySetLocation = qq~$adminurl?action=modcss;cssfile=$FORM{'cssfile'}~;
2949        redirectexit();
2950
2951    }
2952    elsif ( $FORM{'button'} == 2 ) {
2953        $style_name = $FORM{'savecssas'};
2954        if ( $style_name eq 'default' ) {
2955            fatal_error('no_delete_default');
2956        }
2957        if (   $style_name !~ m{\A[0-9a-zA-Z_\.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z}sm
2958            || $style_name eq q{} )
2959        {
2960            fatal_error('invalid_template');
2961        }
2962        $style_cnt = $FORM{'stylelink'};
2963        FromHTML($style_cnt);
2964        $style_cnt =~ s/(\*\/)/$1\n\n/gsm;
2965        $style_cnt =~ s/(\/\*)/\n$1/gsm;
2966        $style_cnt =~ s/(\{)/$1\n/gsm;
2967        $style_cnt =~ s/(\})/$1\n/gsm;
2968        $style_cnt =~ s/(\;)/$1\n/gsm;
2969        @style_arr = split /\n/xsm, $style_cnt;
2970
2971        fopen( TMPCSS, ">$htmldir/Templates/Forum/$style_name.css" )
2972          || fatal_error( 'cannot_open',
2973            "$htmldir/Templates/Forum/$style_name.css", 1 );
2974        foreach my $style_sgl (@style_arr) {
2975            $style_sgl =~ s/\A\s+?//gxsm;
2976            if ( $style_sgl =~ m{\;+\Z}sm ) { $style_sgl = qq~\t$style_sgl~; }
2977            $style_sgl =~ s/$yyhtml_root\/Templates\/Forum/\./gsm;
2978            $style_sgl =~ s/$yyhtml_root/\.\.\/\.\./gsm;
2979            print {TMPCSS} "$style_sgl\n" or croak "$croak{'print'} TMPCSS";
2980        }
2981        fclose(TMPCSS);
2982
2983        $yySetLocation = qq~$adminurl?action=modcss;cssfile=$style_name.css~;
2984        redirectexit();
2985
2986    }
2987    elsif ( $FORM{'button'} == 3 ) {
2988        $style_name = $FORM{'cssfile'};
2989        if ( $style_name eq 'default.css' ) {
2990            fatal_error('no_delete_default');
2991        }
2992        unlink "$htmldir/Templates/Forum/$style_name";
2993        $yySetLocation = qq~$adminurl?action=modcss;cssfile=default.css~;
2994        redirectexit();
2995    }
2996    return;
2997}
2998
29991;