This repository was archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmpbns.php
More file actions
498 lines (496 loc) · 16.5 KB
/
smpbns.php
File metadata and controls
498 lines (496 loc) · 16.5 KB
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<?php
function a($url, $text) {
//echo("DEBUG: Function a - parameters: url: ".htmlspecialchars($url)." text: ".htmlspecialchars($text)."<br />");
return "<a href=".$url.">".$text."</a>";
}
function img($url) {
//echo("DEBUG: Function img - parameters: url: ".htmlspecialchars($url)."<br />");
return "<img src=".'"'.$url.'"'." />";
}
function ob($type, $data) {
//echo("DEBUG: Function object - parameters: type: ".htmlspecialchars($type)." data: ".htmlspecialchars($data)."<br />");
return "<object type=".$type." data=".'"'.$data.'"'.">SMPBNS Code parsed object</object>";
}
function b($text) {
//echo("DEBUG: Function b - parameters: text: ".htmlspecialchars($text)."<br />");
return '<font style = "font-weight: bold">'.$text."</font>";
}
function i($text) {
//echo("DEBUG: Function i - parameters: text: ".htmlspecialchars($text)."<br />");
return '<font style = "font-style: italic">'.$text."</font>";
}
function u($text) {
//echo("DEBUG: Function u - parameters: text: ".htmlspecialchars($text)."<br />");
return '<font style = "text-decoration: underline">'.$text."</font>";
}
function col($col, $text) {
//echo("DEBUG: Function color - parameters: col: ".htmlspecialchars($col)." text: ".htmlspecialchars($text)."<br />");
return '<font style = "color: '.$col.'">'.$text."</font>";
}
function parse($toparse) {
//echo("DEBUG: Function parse START<br />");
$action = "parse";
$output = "";
$code = "";
$text = "";
$url = "";
$type = "";
$col = "";
$subaction = "";
$subcode = "";
for($i = 0; $i < strlen($toparse); $i++) {
if($action == "parse") {
//echo("DEBUG: Action: parse<br />");
if($toparse[$i] == "\n") {
//echo("DEBUG: Parsed endl, inserting br<br />");
$output .= "<br />";
} else if($toparse[$i] == '[') {
//echo("DEBUG: Code detected, reading...<br />");
$code = "";
$action = "getcode";
} else {
//echo("DEBUG: Adding normal char to output...<br />");
$output .= $toparse[$i];
}
} else if($action == "getcode") {
//echo("DEBUG: Action: getcode<br />");
if($toparse[$i] != "]") {
//echo("DEBUG: Adding normal char to code...<br />");
$code .= $toparse[$i];
} else {
//echo("DEBUG: End of code detected, parsing...<br />");
$action = "codeparse";
}
} else if($action == "codeparse") {
//echo("DEBUG: Action: codeparse<br />");
if($code == "b") {
//echo("DEBUG: b code detected, switching to b...<br />");
$action = "b";
$subaction = "text";
} else if($code == "i") {
//echo("DEBUG: i code detected, switching to i...<br />");
$action = "i";
$subaction = "text";
} else if($code == "u") {
//echo("DEBUG: u code detected, switching to u...<br />");
$action = "u";
$subaction = "text";
} else if($code == "img") {
//echo("DEBUG: img code detected, switching to img...<br />");
$action = "img";
$subaction = "text";
} else if($code[0] == 'a') {
//echo("DEBUG: a code detected...<br />");
if($code[1] == "=") {
//echo("DEBUG: Custom a code detected, switching to ac...<br />");
$action = "ac";
$subaction = "url";
} else {
//echo("DEBUG: Simple a code detected, switching to a...<br />");
$action = "a";
$subaction = "text";
}
} else if($code[0] == 'o' AND $code[1] == 'b' AND $code[2] == 'j' AND $code[3] == 'e' AND $code[4] == 'c' AND $code[5] == 't') {
//echo("DEBUG: object code detected, switching to object...<br />");
$action = "object";
$subaction = "type";
} else if($code[0] == 'c' AND $code[1] == 'o' AND $code[2] == 'l' AND $code[3] == 'o' AND $code[4] == 'r') {
//echo("DEBUG: color code detected, switching to color...<br />");
$action = "color";
$subaction = "col";
}
}
if($action == "b") {
//echo("DEBUG: Action: b<br />");
if($subaction == "code") {
//echo("DEBUG: b: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/b") {
//echo("DEBUG: b: Parsed end of b, executing function...<br />");
$output .= b(parse($text));
//echo("DEBUG: b: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: b: This code is not the end of b, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: b: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: b: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: b: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: b: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "i") {
//echo("DEBUG: Action: i<br />");
if($subaction == "code") {
//echo("DEBUG: i: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/i") {
//echo("DEBUG: i: Parsed end of i, executing function...<br />");
$output .= i(parse($text));
//echo("DEBUG: i: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: i: This code is not the end of i, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: i: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: i: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: i: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: i: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "u") {
//echo("DEBUG: Action: u<br />");
if($subaction == "code") {
//echo("DEBUG: u: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/u") {
//echo("DEBUG: u: Parsed end of u, executing function...<br />");
$output .= u(parse($text));
//echo("DEBUG: u: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$action = "parse";
} else {
//echo("DEBUG: u: This code is not the end of u, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: u: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: u: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: u: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: u: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "img") {
//echo("DEBUG: Action: img<br />");
if($subaction == "code") {
//echo("DEBUG: img: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/img") {
//echo("DEBUG: img: Parsed end of img, executing function...<br />");
$output .= img(parse($text));
//echo("DEBUG: img: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: img: This code is not the end of img, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
// echo("DEBUG: img: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: img: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: img: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: img: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "a") {
//echo("DEBUG: Action: a<br />");
if($subaction == "code") {
//echo("DEBUG: a: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/a") {
// echo("DEBUG: a: Parsed end of a, executing function...<br />");
$output .= a($text, parse($text));
//echo("DEBUG: a: Clearing vars and switching back to parse...<br />");
$text = "";
$subcode = "";
$subaction = "";
$action = "parse";
} else {
//echo("DEBUG: a: This code is not the end of a, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: a: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: a: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: a: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: a: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "ac") {
//echo("DEBUG: Action: ac<br />");
if($subaction == "code") {
//echo("DEBUG: ac: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/a") {
//echo("DEBUG: ac: Parsed end of a, executing function...<br />");
$output .= a($url, parse($text));
//echo("DEBUG: ac: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$url = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: ac: This code is not the end of a, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: ac: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: ac: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: ac: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: ac: Getting char to text...<br />");
$text .= $toparse[$i];
} else if($subaction = "url") {
//echo("DEBUG: ac: Subaction: url<br />");
//echo("CODE: ".$code."<br />");
for($k = 2; $k < strlen($code); $k++) {
//echo("DEBUG: ac: Reading url from code... (".$k.")<br />");
$url .= $code[$k];
}
//echo("DEBUG: ac: url reading finished, switching mode...<br />");
$subaction = "text";
//echo("DEBUG: ac: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "object") {
//echo("DEBUG: Action: object<br />");
if($subaction == "code") {
//echo("DEBUG: object: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/object") {
//echo("DEBUG: object: Parsed end of object, executing function...<br />");
$output .= ob($type, parse($text));
// echo("DEBUG: object: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$type = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: object: This code is not the end of object, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: object: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: object: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: object: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: object: Getting char to text...<br />");
$text .= $toparse[$i];
} else if($subaction = "type") {
//echo("DEBUG: object: Subaction: type<br />");
for($k = 6; $k < strlen($code); $k++) {
//echo("DEBUG: object: Reading type from code... (".$k.")<br />");
$type .= $code[$k];
}
//echo("DEBUG: object: type reading finished, switching mode...<br />");
$subaction = "text";
//echo("DEBUG: object: Getting char to text...<br />");
$text .= $toparse[$i];
}
} else if($action == "color") {
//echo("DEBUG: Action: color<br />");
if($subaction == "code") {
//echo("DEBUG: color: Subaction: code<br />");
if($toparse[$i] == "]") {
if($subcode == "/color") {
//echo("DEBUG: color: Parsed end of color, executing function...<br />");
$output .= col($col, parse($text));
//echo("DEBUG: color: Clearing vars and switching back to parse...<br />");
$subcode = "";
$subaction = "";
$col = "";
$text = "";
$action = "parse";
} else {
//echo("DEBUG: color: This code is not the end of color, adding to text and switching mode...<br />");
$text .= '[';
$text .= $subcode;
$text .= $toparse[$i];
$subcode = "";
$subaction = "text";
}
} else {
//echo("DEBUG: color: Getting char to subcode...<br />");
$subcode .= $toparse[$i];
}
} else if($subaction == "text") {
//echo("DEBUG: color: Subaction: text<br />");
if($toparse[$i] == "[") {
//echo("DEBUG: color: Code detected, switching mode...<br />");
$subaction = "code";
continue;
}
//echo("DEBUG: color: Getting char to text...<br />");
$text .= $toparse[$i];
} else if($subaction = "col") {
//echo("DEBUG: color: Subaction: col<br />");
for($k = 6; $k < strlen($code); $k++) {
//echo("DEBUG: color: Reading color from code... (".$k.")<br />");
$col .= $code[$k];
}
//echo("DEBUG: color: color reading finished, switching mode...<br />");
$subaction = "text";
//echo("DEBUG: color: Getting char to text...<br />");
$text .= $toparse[$i];
}
}
}
//echo("DEBUG: Function parse END <br /> OUTPUT: ".htmlspecialchars($output)."<br />");
return $output;
}
?>
<html>
<head>
<title>Phitherek_' s SMPBNS - Główny plik systemu - ten tytuł można później zmienić</title>
<META http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- Tutaj ewentualnie dołączyć plik stylu CSS -->
</head>
<body>
<?php
if(file_exists("smpbns_settings.php")) {
include("smpbns_settings.php");
$baza=mysql_connect($serek, $dbuser, $dbpass) or die("Nie można się połączyć z serwerem MySQL! Czy na pewno instalacja dobiegła końca?");
mysql_select_db($dbname);
$dball=mysql_query("SELECT * FROM ".$dbprefix."news_main");
$rows=mysql_num_rows($dball);
if($rows != NULL) {
for($id = 1; $id <= $rows; $id++) {
$query=mysql_query("SELECT parse FROM ".$dbprefix."news_main WHERE id=".$id);
$parse=mysql_fetch_array($query);
$query=mysql_query("SELECT title FROM ".$dbprefix."news_main WHERE id=".$id);
$title=mysql_fetch_array($query);
if($title != NULL) {
if($parse['parse'] == false OR $parse == NULL) {
?>
<h3 class="smpbns_title"><?php echo $title['title']; ?></h3><hr />
<?php
} else {
?>
<h3 class="smpbns_title"><?php echo parse($title['title']); ?></h3><hr />
<?php
}
} else {
?>
<h3 class="smpbns_title">Brak tytułu</h3><hr />
<?php
}
$query=mysql_query("SELECT content FROM ".$dbprefix."news_main WHERE id=".$id);
$content=mysql_fetch_array($query);
if($content != NULL) {
if($parse['parse'] == false OR $parse == NULL) {
?>
<p class="smpbns_news"><?php echo $content['content']; ?></p><hr />
<?php
} else {
?>
<p class="smpbns_news"><?php echo parse($content['content']); ?></p><hr />
<?php
}
} else {
?>
<p class="smpbns_news">Brak treści</p><hr />
<?php
}
$query=mysql_query("SELECT added FROM ".$dbprefix."news_main WHERE id=".$id);
$added=mysql_fetch_array($query);
?>
<p class="smpbns_date">Ostatnia aktualizacja wiadomości: <?php echo $added['added']; ?></p><br /><br />
<?php
}
} else {
?>
<p class="smpbns_info">Brak rekordów w bazie danych</p>
<?php
}
mysql_close($baza);
} else {
?>
<p class="smpbns_error">Plik ustawień nie istnieje! Czy na pewno uruchomiłeś install.php?</p>
<?php
}
?>
<a class="smpbns_admin" href="smpbns_mod.php" title="Moderacja">Moderacja</a><br />
<hr />
<p class="smpbns_footer">Powered by <a class="smpbns_footer" href="http://www.smpbns.phitherek.cba.pl" title="SMPBNS">SMPBNS</a> | © 2009-2011 by Phitherek_</p>
</body>
</html>