-
Notifications
You must be signed in to change notification settings - Fork 18
/
signaturebuilder.php
259 lines (225 loc) · 8.62 KB
/
signaturebuilder.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/***************************************************************************
*
* 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.
*
* Portions of this program are derived from publicly licensed software
* projects including, but not limited to phpBB, Magelo Clone,
* EQEmulator, EQEditor, and Allakhazam Clone.
*
* Author:
* Maudigan(Airwalking)
*
* September 28, 2014 - Maudigan
* added code to monitor database performance
* May 24, 2016 - Maudigan
* turned the code that converts filenames in a directory
* into the option lists into a function.
* general code cleanup, whitespace correction, removed old comments,
* organized some code. A lot has changed, but not much functionally
* do a compare to 2.41 to see the differences.
* Implemented new database wrapper.
* March 14, 2020
* show char menu if we come in with a charname
* display optional charname in form
* March 22, 2020 - Maudigan
* impemented common.php
***************************************************************************/
/*********************************************
INCLUDES
*********************************************/
//define this as an entry point to unlock includes
if ( !defined('INCHARBROWSER') )
{
define('INCHARBROWSER', true);
}
include_once(__DIR__ . "/include/common.php");
/*********************************************
SUPPORT FUNCTIONS
*********************************************/
//for getting server locations for bbcode
function GetFileDir($php_self){
$filename2 = "";
$filename = explode("/", $php_self); // THIS WILL BREAK DOWN THE PATH INTO AN ARRAY
for( $i = 0; $i < (cb_count($filename) - 1); ++$i ) {
$filename2 .= $filename[$i].'/';
}
return $filename2;
}
//converts a directory into a list of options
function DirectoryToOptions($directory) {
$filehandle = opendir($directory);
$return = array();
while (false != ($file = readdir($filehandle))) {
$name = explode(".", $file);
if ($name[0])
$return[] = $name[0];
}
closedir($filehandle);
return $return;
}
/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//don't bother letting them build a signature
//if the server doesnt have GD installed
if (!SERVER_HAS_GD) {
$cb_error->message_die($language['MESSAGE_ERROR'], $language['MESSAGE_NO_GD']);
}
//prepopulate name if its provided
$charName = preg_Get_Post('char', '/^[a-zA-Z]+$/', false);
//build all the option lists for the dropdown boxes
//most are based off the files present in a directory
//some are static.
$epicborders = DirectoryToOptions(__DIR__."/images/signatures/epicborders");
$statborders = DirectoryToOptions(__DIR__."/images/signatures/statborders");
$borders = DirectoryToOptions(__DIR__."/images/signatures/borders");
$backgrounds = DirectoryToOptions(__DIR__."/images/signatures/backgrounds");
$screens = DirectoryToOptions(__DIR__."/images/signatures/screens");
if (SERVER_HAS_FREETYPE)
$fonts = DirectoryToOptions(__DIR__."/fonts");
else
$fonts = DirectoryToOptions(__DIR__."/fontsold"); //use old fonts if we can't handle TTF
$stats = array(
'REGEN', 'FT', 'DS', 'HASTE', 'HP', 'MANA', 'ENDR', 'AC', 'ATK', 'STR', 'STA', 'DEX',
'AGI', 'INT', 'WIS', 'CHA', 'PR', 'FR', 'MR', 'DR', 'CR', 'WT'
);
/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$language['PAGE_TITLES_SIGBUILD'];
include(__DIR__ . "/include/header.php");
/*********************************************
DROP PROFILE MENU
*********************************************/
//only drop this header if we came in with a character name
if ($charName) {
output_profile_menu($charName, 'signaturebuilder');
}
/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'settings' => 'settings_body.tpl')
);
$cb_template->set_filenames(array(
'sigbuild' => 'signature_builder_body.tpl')
);
$cb_template->assign_vars(array(
'CHARNAME' => $charName,
'SIGNATURE_ROOT_URL' => ($charbrowser_root_url) ? $charbrowser_root_url : "http://".$_SERVER['HTTP_HOST'].GetFileDir($_SERVER['PHP_SELF']),
'SIGNATURE_INDEX_URL' => "http://".$_SERVER['HTTP_HOST'].GetFileDir($_SERVER['PHP_SELF']) . (($charbrowser_wrapped) ? $_SERVER['SCRIPT_NAME'] : "index.php"),
'CAN_CHANGE_FONT_SIZE' => (SERVER_HAS_FREETYPE) ? "" : "Disabled",
'L_SIGNATURE_BUILDER' => $language['SIGNATURE_SIGNATURE_BUILDER'],
'L_NAME' => $language['SIGNATURE_NAME'],
'L_FONT_ONE' => $language['SIGNATURE_FONT_ONE'],
'L_FONT_SIZE_ONE' => $language['SIGNATURE_FONT_SIZE_ONE'],
'L_FONT_COLOR_ONE' => $language['SIGNATURE_FONT_COLOR_ONE'],
'L_FONT_SHADOW_ONE' => $language['SIGNATURE_FONT_SHADOW_ONE'],
'L_FONT_TWO' => $language['SIGNATURE_FONT_TWO'],
'L_FONT_SIZE_TWO' => $language['SIGNATURE_FONT_SIZE_TWO'],
'L_FONT_COLOR_TWO' => $language['SIGNATURE_FONT_COLOR_TWO'],
'L_FONT_SHADOW_TWO' => $language['SIGNATURE_FONT_SHADOW_TWO'],
'L_EPIC_BORDER' => $language['SIGNATURE_EPIC_BORDER'],
'L_STAT_BORDER' => $language['SIGNATURE_STAT_BORDER'],
'L_STAT_COLOR' => $language['SIGNATURE_STAT_COLOR'],
'L_STATS' => $language['SIGNATURE_STATS'],
'L_MAIN_BORDER' => $language['SIGNATURE_MAIN_BORDER'],
'L_MAIN_BACKGROUND' => $language['SIGNATURE_MAIN_BACKGROUND'],
'L_MAIN_COLOR' => $language['SIGNATURE_MAIN_COLOR'],
'L_MAIN_SCREEN' => $language['SIGNATURE_MAIN_SCREEN'],
'L_PREVIEW' => $language['SIGNATURE_PREVIEW'],
'L_CREATE' => $language['SIGNATURE_CREATE'],
'L_BBCODE' => $language['SIGNATURE_BBCODE'],
'L_HTML' => $language['SIGNATURE_HTML'],
'L_NEED_NAME' => $language['SIGNATURE_NEED_NAME'])
);
//display tabs
foreach($language['SIGNATURE_TABS'] as $key => $value)
$cb_template->assign_block_vars("tabs", array(
'ID' => $key,
'TEXT' => $value)
);
//fonts
foreach($fonts as $value)
$cb_template->assign_block_vars("font", array(
'TEXT' => $value,
'VALUE' => $value)
);
//epic borders
$cb_template->assign_block_vars("epicborders", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_EPIC'],
'VALUE' => 0)
);
foreach($epicborders as $value)
$cb_template->assign_block_vars("epicborders", array(
'TEXT' => $value,
'VALUE' => $value)
);
//stat borders
$cb_template->assign_block_vars("statborders", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_STAT_ALL'],
'VALUE' => 0)
);
foreach($statborders as $value)
$cb_template->assign_block_vars("statborders", array(
'TEXT' => $value,
'VALUE' => $value)
);
//stats
$cb_template->assign_block_vars("stats", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_STAT_IND'],
'VALUE' => 0)
);
foreach($stats as $value)
$cb_template->assign_block_vars("stats", array(
'TEXT' => $value,
'VALUE' => $value)
);
//borders
$cb_template->assign_block_vars("borders", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_BORDER'],
'VALUE' => 0)
);
foreach($borders as $value)
$cb_template->assign_block_vars("borders", array(
'TEXT' => $value,
'VALUE' => $value)
);
//backgrounds
$cb_template->assign_block_vars("backgrounds", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_BACKGROUND'],
'VALUE' => 0)
);
foreach($backgrounds as $value)
$cb_template->assign_block_vars("backgrounds", array(
'TEXT' => $value,
'VALUE' => $value)
);
//screen filters
$cb_template->assign_block_vars("screens", array( //insert an "off" option first
'TEXT' => $language['SIGNATURE_OPTION_SCREEN'],
'VALUE' => 0)
);
foreach($screens as $value)
$cb_template->assign_block_vars("screens", array(
'TEXT' => $value,
'VALUE' => $value)
);
//font sizes
for ($i = 5; $i <= 40; $i++ ) {
$cb_template->assign_block_vars("fontsize", array(
'TEXT' => $i,
'VALUE' => $i)
);
}
/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('sigbuild');
$cb_template->destroy();
include(__DIR__ . "/include/footer.php");
?>