C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\admin\t-editor.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
/* $Id: t-editor.php,v 1.2 2002/12/20 21:56:36 dkreuer Exp $ */
/*
          ThWboard - PHP/MySQL Bulletin Board System
        ==============================================
            (c) 2000, 2001 by
               Paul Baecher         <paul@thewall.de>
               Felix Gonschorek   <funner@thewall.de>

          download the latest version:
            http://www.thwboard.de

          This  program is  free  software;  you can
          redistribute it and/or modify it under the
          terms of the GNU General Public License as
          published by the Free Software Foundation;
          either  version 2 of  the License,  or (at
          your option) any later version.

        ==============================================

*/

include "common.inc.php";
include 
"fileaccess.inc.php";

tb_header();

function 
EditboxEncode($string)
{
    
$string str_replace('&''&amp;'$string);
    
$string str_replace('"''&quot;'$string);
    
$string str_replace('<''&lt;'$string);
    
$string str_replace('>''&gt;'$string);
    
    return 
$string;
}

function 
EditboxDecode($string)
{
    
$string str_replace('&amp;''&'$string);
    
$string str_replace('&quot;''"'$string);
    
$string str_replace('&lt;''<'$string);
    
$string str_replace('&gt;''>'$string);

    return 
$string;
}

$a_replace = array(
    
'$style[stdfont]' => '{font}',
    
'$style[stdfontend]' => '{/font}',
    
'$style[smallfont]' => '{sfont}',
    
'$style[smallfontend]' => '{/sfont}',
    
'$style[colorbg]' => '{bgcolor}',
    
'$style[colorbgfont]' => '{bgfontcolor}',
    
'$style[color1]' => '{textcolor}',
    
'$style[CellA]' => '{cellbg}',
    
'$style[CellB]' => '{altcellbg}',
    
'$style[col_he_fo_font]' => '{he_fo_color}',
    
'$style[color4]' => '{tableheaderbg}',
    
'$style[border_col]' => '{tablebordercolor}',
    
'$style[color_err]' => '{errorcolor}',
    
'$style[col_link]' => '{linkcolor}',
    
'$style[col_link_v]' => '{visitedlinkcolor}',
    
'$style[col_link_hover]' => '{hoverlinkcolor}'
);

if( 
$action == "EditTemplate" )
{
    if( !
$name )
    {
        print 
'no template name specified!';
    }
    elseif ( !
$dir)
    {
        print 
'no template-directory specified!';
    }
    else
    {
        if( !
file_exists('../templates/' $dir '/' $name) )
        {
            print 
'template ' $name '.html does not exist!';
        }
        else
        {
            if( !
WriteAccess('../templates/' $dir '/' $name) )
            {
                print 
"can't edit file '$name.html': no write permission (set chmod 666 or 777)";
            }
            else
            {
                
$t_data = @implode("", (@file('../templates/' $dir '/' $name)));

                while( list(
$k$v) = each($a_replace) )
                {
                    
$t_data str_replace($k$v$t_data);
                }
                print 
'<b>Edit Template: "' $name '"</b><br><br>';
                print 
'<form action="t-editor.php" method="post">
<textarea wrap="OFF" name="t_data" class="htmlsource" cols="100" rows="32">' 
EditboxEncode($t_data) . '</textarea><br><br><br>
<input type="hidden" name="action" value="UpdateTemplate">
<input type="hidden" name="name" value="' 
$name '">
<input type="hidden" name="dir" value="' 
$dir '">
<input type="hidden" name="session" value="' 
$session '">
<input type="submit" name="Submit" value="Update Template">
</form>'
;
                print 
'<b>available inserts:</b><br> {font} / {/font} - default font<br>
                    {sfont} / {/sfont} - small font<br>
                    {bgcolor} - body background color<br>
                    {bgfontcolor} - body background font color<br>
                    {textcolor} - text color within tables<br>
                    {cellbg} - cell background color<br>
                    {altcellbg} - 2nd cell bg color<br>
                    {tableheaderbg} - table header and footer background<br>
                    {he_fo_color} - font color for table headers and footers<br>
                    {tablebordercolor} - color between cells<br>'
;
            }
        }
    }
}
elseif( 
$action == "UpdateTemplate" )
{
    if( !
$name )
    {
        print 
'no template specified!';
    }
    elseif ( !
$dir)
    {
        print 
'no template-directory specified!';
    }
    else
    {
        
$fp fopen('../templates/' $dir '/' $name'w');
        if( !
$fp )
        {
            print 
'unable to open template file "' $name '" for write access. check chmod! (should be 666 or 777)';
        }
        else
        {
            while( list(
$k$v) = each($a_replace) )
            {
                
$t_data str_replace($v$k$t_data);
            }
            
$t_data str_replace("\r\n""\n"$t_data);
            
fwrite($fpstripslashes(EditboxDecode($t_data)));
            
fclose($fp);
        
            print 
'template has been updated!<br>click <a href="t-editor.php?action=EditTemplate&name=' $name '&session=' $session '&dir=' $dir '">here</a> to continue.';
        }
    }
}
elseif( 
$action == "ListTemplateSets" )
{
    print 
'<b>Templates Sets</b><br><br>';
    
$path "../templates";
    
$tempdir opendir($path);
    while( 
$tempsetdir readdir($tempdir) )
    {
        if  ( ( 
$tempsetdir != ".." ) && ( $tempsetdir != "." ) &&
        ( 
$tempsetdir != "mail" ) && ( is_dir($path."/".$tempsetdir) &&
        
$tempsetdir != 'CVS' ) )
        {
            print(
"[ <A HREF=\"t-editor.php?session=" $session "&action=ListTemplates&dir=$tempsetdir\">$tempsetdir</A> ]<BR><BR>");
        }
    }
}
elseif( 
$action == "ListTemplates" )
{
    if ( !
$dir )
    {
    print 
'no template-directory specified!';
    }
    else
    {
        print 
'<b>Templates</b><br><br>';
        
$h opendir('../templates/' $dir '/');
        
$a_templates = array();
        while( 
$file readdir($h) )
        {
            if( 
substr($file, -5) == '.mail' || substr($file, -5) == '.html' )
            {
                
$a_templates[] = $file;
            }
        }
        
        
sort($a_templates);
        
        print 
'<table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr> 
        <td><b>Filename</b></td>
        <td><b>Options</b></td>
        <td><b>Size</b></td>
        <td><b>Modified</b></td>
      </tr>'
;
        
        while( list(
$k$file) = each($a_templates) )
        {
            if( !
WriteAccess('../templates/' $dir '/' $file) )
            {
                print 
'
      <tr> 
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.$file.'</td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>Can'."'".'t edit: No permission</td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.ceil(filesize('../templates/' $dir '/'.$file)/1000).' KB</td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.date('d.m.Y, H:i'filemtime('../templates/' $dir '/'.$file)).'</td>
      </tr>'
;
            }
            else
            {
                print 
'
      <tr> 
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.$file.'</td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'><a href="t-editor.php?action=EditTemplate&session='.$session.'&name='.$file.'&dir=' $dir '">Edit</a></td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.ceil(filesize('../templates/' $dir '/'.$file)/1000).' KB</td>
        <td'
.($k == ' bgcolor="#eeeeee"' '').'>'.date('d.m.Y, H:i'filemtime('../templates/' $dir '/'.$file)).'</td>
      </tr>'
;
            }
        }
        print 
'</table>';
    }
}


tb_footer();

?>