-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmzn2.php
832 lines (754 loc) · 51.3 KB
/
mzn2.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
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
<?php
/////////////////////////////////////////////////////////////////////////////
// //
// __ __ ____ ___ //
// | \/ | |_ / _ _ ® |_ ) //
// | |\/| | / / | ' \ / / //
// |_| |_| /___| |_||_| /___| //
// //
// //
// Copyright 2003-2004 WsTec - Todos os direitos reservados //
// //
////////////////////////////////////// by Wesley de Souza - GokuSSJ5 ////
// //
// É ALTAMENTE PERIGOSA QUALQUER ALTERAÇÃO A PARTIR DESTE PONTO! //
// //
/////////////////////////////////////////////////////////////////////////////
error_reporting(7); set_magic_quotes_runtime(0);
define("WsSys_Token", 1);
if (!$mzn_path) {echo "<b>Erro!</b> - Caminho não localizado!"; exit; }
if (!file_exists($mzn_path ."/inc/g_global.php")) {echo "<b>Erro!</b> - Caminho inválido!"; exit; }
unset($s); unset($m);
$AbsPath = $mzn_path;
require_once $mzn_path ."/inc/g_global.php";
require_once $mzn_path ."/inc/g_config.php";
$s = new WsSys;
$s->cfg = $c;
$s->debug = 1;
require_once $AbsPath ."/inc/g_mzn2.php";
$m = new MZn2;
// Condição de existência do banco de dados
$system_ok = 0;
if (@file_exists($s->cfg['file']['mzn2_safe'])) {$system_ok = 1; $m->remoteStart(); }
class MZn2_Noticias {
var $categoria = "principal";
var $ordenar_por = "data";
var $ordem = "decrescente";
var $data = "";
var $busca = "";
var $usuario = "";
var $noticia = "";
var $porpagina = 10;
var $pagina = 1;
var $paginas = 1;
var $ip = "";
var $mostrar_agrupamento_diario = 1;
var $mostrar_link_noticia_completa = 1;
var $dbC = array();
var $dbN = array();
var $filterFind = array();
var $filterRepl = array();
var $msg = "O MZn² ainda não foi instalado.";
// Constructor
function MZn2_Noticias () {
global $s, $m, $system_ok;
if (!$system_ok) {return; }
if (!$this->pagina) {$this->pagina = 1; }
$this->dbC = $s->db_table_open($s->cfg['file']['comments']); $this->dbC = $this->dbC['data'];
$this->dbN = $s->db_table_open($s->cfg['file']['news']); $this->dbN = $this->dbN['data'];
$this->filter_load();
$addrs = array();
foreach(array_reverse(explode(",", $s->req['HTTP_X_FORWARDED_FOR'])) as $x_f) {
$x_f = trim($x_f);
if (preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $x_f )) {$addrs[] = $x_f; }
}
$addrs[] = $s->req['REMOTE_ADDR'];
$addrs[] = $s->req['HTTP_PROXY_USER'];
$ip = $this->select_var($addrs);
$ip = preg_replace("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3.\\4", $ip);
$s->req['REMOTE_ADDR'] = $ip;
$this->ip = $ip;
}
function select_var($array) {
if (!is_array($array)) {return ""; } ksort($array);
$chosen = "";
foreach ($array as $k => $v) {
if (isset($v)) {
$chosen = $v;
break;
}
}
return $chosen;
}
function verify_ip () {
global $s, $m;
$user_ip = $this->ip; $blocked = $s->sys['visitor']['blockip'];
if (!$user_ip) {return false; }
if (!$blocked) {return true; }
$blocked = explode(",", $blocked);
foreach ($blocked as $ip) {
$ip = $s->regex_safe($ip);
$ip = str_replace("\\*", "[0-9]{1,3}", $ip);
if (preg_match("/". $ip ."/iU", $user_ip)) {return false; }
}
return true;
}
function test_login ($v1, $v2) {
global $s;
if (md5($v1) == $v2) {return true; }
else {return false; }
}
function tpl ($tpl, $replace = array(), $useFrom = "") {
global $s, $m, $system_ok;
if ($system_ok) {
$cat = $this->categoria; if ($useFrom) {$cat = $useFrom; }
if ($s->cat[$cat]['templates']['usefrom']) {return $this->tpl($tpl, $replace, $s->cat[$cat]['templates']['usefrom']); }
if (!$s->cat[$cat]['templates'][$tpl]) {return ""; }
$res = $s->cat[$cat]['templates'][$tpl];
foreach ($replace as $k => $v) {
$res = str_replace("{". $k ."}", $v, $res);
}
return $res;
}
}
function parse_date ($date, $time) {
global $s;
$weekds = array("0" => "Domingo", "1" => "Segunda", "2" => "Terça", "3" => "Quarta", "4" => "Quinta", "5" => "Sexta", "6" => "Sábado");
$months = array("01" => "Janeiro", "02" => "Fevereiro", "03" => "Março", "04" => "Abril", "05" => "Maio", "06" => "Junho", "07" => "Julho", "08" => "Agosto", "09" => "Setembro", "10" => "Outubro", "11" => "Novembro", "12" => "Dezembro");
$weekds_s = array("0" => "Dom", "1" => "Seg", "2" => "Ter", "3" => "Qua", "4" => "Qui", "5" => "Sex", "6" => "Sáb");
$months_s = array("01" => "Jan", "02" => "Fev", "03" => "Mar", "04" => "Abr", "05" => "Mai", "06" => "Jun", "07" => "Jul", "08" => "Ago", "09" => "Set", "10" => "Out", "11" => "Nov", "12" => "Dez");
$date = str_replace("%F", $months[date("m", $time)], $date);
$date = str_replace("%l", $weekds[date("m", $time)], $date);
$date = str_replace("%M", $months_s[date("m", $time)], $date);
$date = str_replace("%D", $weekds_s[date("m", $time)], $date);
$date_res = array(); preg_match_all("/%(.)/U", $date, $date_res); foreach ($date_res[1] as $v2) {$date = preg_replace("/%". $v2 ."/U", date($v2, $time), $date); }
return $date;
}
function parse_date_adv ($str, $time, $prefix) {
global $s;
$weekds = array("0" => "Domingo", "1" => "Segunda", "2" => "Terça", "3" => "Quarta", "4" => "Quinta", "5" => "Sexta", "6" => "Sábado");
$months = array("01" => "Janeiro", "02" => "Fevereiro", "03" => "Março", "04" => "Abril", "05" => "Maio", "06" => "Junho", "07" => "Julho", "08" => "Agosto", "09" => "Setembro", "10" => "Outubro", "11" => "Novembro", "12" => "Dezembro");
$weekds_s = array("0" => "Dom", "1" => "Seg", "2" => "Ter", "3" => "Qua", "4" => "Qui", "5" => "Sex", "6" => "Sáb");
$months_s = array("01" => "Jan", "02" => "Fev", "03" => "Mar", "04" => "Abr", "05" => "Mai", "06" => "Jun", "07" => "Jul", "08" => "Ago", "09" => "Set", "10" => "Out", "11" => "Nov", "12" => "Dez");
$str = str_replace("{". $prefix ."%F}", $months[date("m", $time)], $str);
$str = str_replace("{". $prefix ."%l}", $weekds[date("w", $time)], $str);
$str = str_replace("{". $prefix ."%M}", $months_s[date("m", $time)], $str);
$str = str_replace("{". $prefix ."%D}", $weekds_s[date("w", $time)], $str);
$str_res = array(); preg_match_all("/\{". $s->regex_safe($prefix) ."%(.)\}/U", $str, $str_res); foreach ($str_res[1] as $v2) {$str = preg_replace("/\{". $s->regex_safe($prefix) ."%". $v2 ."\}/", date($v2, $time), $str); }
return $str;
}
function filter_load () {
global $s, $m;
$list = trim($s->sys['filter']['list']); $list = explode("\n", $list);
foreach ($list as $item) {
list($find, $replace) = explode("=", $item, 2);
$find = $s->simple_string($find); $find = $s->regex_search($find);
$this->filterFind[] = "/". $find ."/i";
$this->filterRepl[] = $replace;
}
}
function verify_name ($name) {
global $s, $m;
$name = $s->simple_string($name);
$list = trim($s->sys['visitor']['lock_custom']); $list = explode("\n", $list);
foreach ($list as $find) {
$find = $s->simple_string($find); $find = $s->regex_search($find);
if (preg_match("/". $find ."/iU", $name)) {return false; }
}
foreach ($s->users as $v) {
$find = $v['name']; $find = $s->simple_string($find); $find = $s->regex_safe($find);
if (preg_match("/". $find ."/iU", $name)) {return false; }
}
return true;
}
function news_parse ($contents, $nobr = 0, $nocode = 0, $nosmilies = 0, $nohtml = 0) {
global $s;
$res = $contents;
if ($nohtml) {
$res = str_replace("<", "<", $res);
$res = str_replace(">", ">", $res);
}
if (!$nobr) {
if ($nocode) {$res = str_replace("\n", "<br />", $res);}
else {$res = str_replace("\n", "[br]", $res); }
}
if (!$nosmilies) {
$smFind = array(); $smRepl = array(); foreach ($s->smPack as $smTx => $smUrl) {if ($nohtml) {$smTx = str_replace("<", "<", $smTx); $smTx = str_replace(">", ">", $smTx); } $smTx = $s->regex_safe($smTx); $smFind[] = "/(^|\s|\])(". $smTx .")(\s|\n|\.|,|\[|$)/"; if ($nocode) {$smRepl[] = "\\1<img src=\"". $smUrl ."\" align=\"absMiddle\" border=\"0\" />\\3"; } else {$smRepl[] = "\\1[img=absMiddle]". $smUrl ."[/img]\\3"; } }
$res = preg_replace($smFind, $smRepl, $res);
}
if (!$nocode) {
$hcFind = array(); $hcRepl = array(); foreach ($s->cfg['hcode']['taglist'] as $hcL) {$hcL = explode("|", $hcL); $hcFind[] = sprintf($s->cfg['hcode'][$hcL[2]], $hcL[0], $hcL[0]); $hcRepl[] = $hcL[1]; }
$res = preg_replace($hcFind, $hcRepl, $res);
$res = preg_replace($hcFind, $hcRepl, $res);
$res = preg_replace($hcFind, $hcRepl, $res);
}
return $res;
}
function mostrar_manchetes() {$this->mostrar_noticias("headlines"); }
// Aliases
function mostrar_headlines() {$this->mostrar_manchetes(); }
function mostrar_cabecalhos() {$this->mostrar_manchetes(); }
function mostrar_cabeçalhos() {$this->mostrar_manchetes(); }
function mostrar_noticias($type = "news") {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$o1 = $s->simple_string($this->ordenar_por); $o2 = $s->simple_string(substr($this->ordem, 0, 1));
if ($this->data) {$data = explode("-", $this->data); }
if ($this->busca) {$busca = $s->regex_search($this->busca); }
if (!$this->pagina) {$this->pagina = 1; }
$comments = array();
foreach ($this->dbC as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q']) {continue; }
if (!$comments[$v['nid']]) {$comments[$v['nid']] = 0; }
$comments[$v['nid']] += 1;
}
$ndb = array();
$i = 0; foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q'] || ($v['data']['t'] && $s->cfg['time'] < $v['time'])) {continue; }
if ($data) {
if ($data[0] && date("Y", $v['time']) != $data[0]) {continue; }
if ($data[1] && date("m", $v['time']) != $data[1]) {continue; }
if ($data[2] && date("d", $v['time']) != $data[2]) {continue; }
}
if ($busca) {
$search = ""; foreach ($v as $item) {if (is_array($item)) {continue; } if ($search) {$search .= "|"; } $search .= $item; }
if (!preg_match("/". $busca ."/iU", $search)) {continue; }
}
if ($this->usuario) {
if ($v['user'] != $this->usuario) {continue; }
}
$k = "";
if ($o1 == "data") {$k .= $v['time']; while (strlen($k) < 20) {$k = "0". $k; } }
else if ($o1 == "usuario") {$k = $s->users[$v['user']]['name']; }
$k .= "|". $i;
$ndb[$k] = $v;
$i++; }
if ($o2 == "d") {krsort($ndb); }
else {ksort($ndb); }
$count = count($ndb); $page = $this->pagina; $perpage = $this->porpagina;
if ($count) {
if ($perpage == 0) {$iStart = 0; $iEnd = $count; $this->paginas = 1; }
else {
$pg_tot = 1; while ($count - $perpage > 0) {$pg_tot++; $count -= $perpage; }
if ($page > $pg_tot) {$page = $pg_tot; } if ($page < 1) {$page = 1; }
$iStart = intval(($page - 1) * $perpage); $iEnd = round($page * $perpage);
$this->paginas = $pg_tot;
}
$res = array();
$i = 0; foreach ($ndb as $k => $v) {
if ($i >= $iStart && $i < $iEnd) {
if (!$comments[$v['id']]) {$comments[$v['id']] = 0; }
if ($s->sys['filter']['news']) {$v['title'] = preg_replace($this->filterFind, $this->filterRepl, $v['title']); $v['news'] = preg_replace($this->filterFind, $this->filterRepl, $v['news']); $v['fnews'] = preg_replace($this->filterFind, $this->filterRepl, $v['fnews']); }
$nohtml = 0; if (!$s->users[$v['user']]['perms'][$this->categoria]['usehtml'] && !$s->users[$v['user']]['perms']['admin']) {$nohtml = 1; }
$v['news'] = $this->news_parse($v['news'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$v['fnews'] = $this->news_parse($v['fnews'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$repl = array();
$repl['system:mzn2dir'] = $s->sys['sys']['dir'];
$repl['system:thispage'] = $s->req['PHP_SELF'];
$repl['news:id'] = $v['id'];
$repl['news:title'] = $v['title']; if ($s->cat[$this->categoria][$type]['cut'] && strlen($repl['news:title']) > $s->cat[$this->categoria][$type]['cut']) {$repl['news:title'] = substr($repl['news:title'], 0, intval($s->cat[$this->categoria][$type]['cut'] - 3)) ."..."; }
$repl['news:title:nocut'] = $v['title'];
$repl['news:contents'] = $v['news'];
$repl['news:full'] = $v['fnews'];
$repl['news:comments'] = $comments[$v['id']]; if ($v['data']['nc']) {$repl['news:comments'] = "-"; }
$date = $this->tpl("date"); $date = $this->parse_date($date, $v['time']);
$repl['news:date'] = $date;
$repl['date:day'] = date("d", $v['time']); $repl['date:month'] = date("m", $v['time']); $repl['date:year'] = date("Y", $v['time']); $repl['date:hour'] = date("H", $v['time']); $repl['date:minute'] = date("i", $v['time']); $repl['date:second'] = date("s", $v['time']);
$repl['user:login'] = $v['user'];
$repl['user:name'] = $s->users[$v['user']]['name'];
$repl['user:mail'] = $s->users[$v['user']]['mail'];
$repl['user:icq'] = $s->users[$v['user']]['icq'];
$repl['user:field1'] = $s->users[$v['user']]['field1'];
$repl['user:field2'] = $s->users[$v['user']]['field2'];
$repl['user:field3'] = $s->users[$v['user']]['field3'];
$repl['user:posts'] = $s->users[$v['user']]['posts'];
if ($v['data']['f'] && $this->mostrar_link_noticia_completa) {$repl['news:contents'] .= $this->tpl("fnews_link", $repl); }
$final = $this->tpl($type, $repl);
$final = $this->parse_date_adv($final, $v['time'], "date:");
$res[date("d/m/Y", $v['time'])] .= $final;
}
$i++;
}
foreach ($res as $k => $day) {
if (strpos($this->tpl("daygroup"), "{news}") !== FALSE && $type == "news" && $this->mostrar_agrupamento_diario) {
$repl = array(); $k = explode("/", $k, 3);
$repl['news'] = $day;
$repl['date:day'] = $k[0];
$repl['date:month'] = $k[1];
$repl['date:year'] = $k[2];
$final = $this->tpl("daygroup", $repl);
$final = $this->parse_date_adv($final, mktime(0, 0, 0, $k[1], $k[0], $k[2]), "date:");
echo $final;
}
else {echo $day; }
}
}
else if ($count == 0) {
if ($busca) {echo "Sua busca não encontrou resultados"; }
else {echo "Não há notícias para exibir"; }
}
}
// Aliases
function mostrar_news() {$this->mostrar_noticias(); }
function mostrar_notícias() {$this->mostrar_noticias(); }
function mostrar_noticia($tpl = "news") {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$comments = array();
foreach ($this->dbC as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q']) {continue; }
if (!$comments[$v['nid']]) {$comments[$v['nid']] = 0; }
$comments[$v['nid']] += 1;
}
$i = 0; foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['id'] != $this->noticia) {continue; }
if (!$comments[$v['id']]) {$comments[$v['id']] = 0; }
if ($s->sys['filter']['news']) {$v['title'] = preg_replace($this->filterFind, $this->filterRepl, $v['title']); $v['news'] = preg_replace($this->filterFind, $this->filterRepl, $v['news']); $v['fnews'] = preg_replace($this->filterFind, $this->filterRepl, $v['fnews']); }
$nohtml = 0; if (!$s->users[$v['user']]['perms'][$this->categoria]['usehtml'] && !$s->users[$v['user']]['perms']['admin']) {$nohtml = 1; }
$v['news'] = $this->news_parse($v['news'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$v['fnews'] = $this->news_parse($v['fnews'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$repl = array();
$repl['system:mzn2dir'] = $s->sys['sys']['dir'];
$repl['system:thispage'] = $s->req['PHP_SELF'];
$repl['news:id'] = $v['id'];
$repl['news:title'] = $v['title']; if ($s->cat[$this->categoria]['news']['cut'] && strlen($repl['news:title']) > $s->cat[$this->categoria]['news']['cut']) {$repl['news:title'] = substr($repl['news:title'], 0, intval($s->cat[$this->categoria]['news']['cut'] - 3)) ."..."; }
$repl['news:title:nocut'] = $v['title'];
$repl['news:contents'] = $v['news'];
$repl['news:full'] = $v['fnews'];
$repl['news:comments'] = $comments[$v['id']]; if ($v['data']['nc']) {$repl['news:comments'] = "-"; }
$date = $this->tpl("date"); $date = $this->parse_date($date, $v['time']);
$repl['news:date'] = $date;
$repl['date:day'] = date("d", $v['time']);
$repl['date:month'] = date("m", $v['time']);
$repl['date:year'] = date("Y", $v['time']);
$repl['date:hour'] = date("H", $v['time']);
$repl['date:minute'] = date("i", $v['time']);
$repl['date:second'] = date("s", $v['time']);
$repl['user:login'] = $v['user'];
$repl['user:name'] = $s->users[$v['user']]['name'];
$repl['user:mail'] = $s->users[$v['user']]['mail'];
$repl['user:icq'] = $s->users[$v['user']]['icq'];
$repl['user:field1'] = $s->users[$v['user']]['field1'];
$repl['user:field2'] = $s->users[$v['user']]['field2'];
$repl['user:field3'] = $s->users[$v['user']]['field3'];
$repl['user:posts'] = $s->users[$v['user']]['posts'];
if ($v['data']['f'] && $this->mostrar_link_noticia_completa) {$repl['news:contents'] .= $this->tpl("fnews_link", $repl); }
$final = $this->tpl($tpl, $repl);
$final = $this->parse_date_adv($final, $v['time'], "date:");
$news = $final;
if (strpos($this->tpl("daygroup"), "{news}") !== FALSE && $this->mostrar_agrupamento_diario) {
$repl = array(); $k = explode("/", date("d/m/Y", $v['time']), 3);
$repl['news'] = $news;
$repl['date:day'] = $k[0];
$repl['date:month'] = $k[1];
$repl['date:year'] = $k[2];
$final = $this->tpl("daygroup", $repl);
$final = $this->parse_date_adv($final, mktime(0, 0, 0, $k[1], $k[0], $k[2]), "date:");
echo $final;
}
else {echo $news; }
break;
}
}
// Aliases
function mostrar_notícia($tpl = "news") {$this->mostrar_noticia($tpl); }
function mostrar_noticia_para_impressao() {
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$this->mostrar_agrupamento_diario = 0;
$this->mostrar_link_noticia_completa = 0;
$this->mostrar_noticia("print");
}
// Aliases
function mostrar_notícia_para_impressão() {$this->mostrar_noticia_para_impressao(); }
function mostrar_noticia_completa() {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$comments = array();
foreach ($this->dbC as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q']) {continue; }
if (!$comments[$v['nid']]) {$comments[$v['nid']] = 0; }
$comments[$v['nid']] += 1;
}
$i = 0; foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['id'] != $this->noticia) {continue; }
if (!$comments[$v['id']]) {$comments[$v['id']] = 0; }
if ($s->sys['filter']['news']) {$v['title'] = preg_replace($this->filterFind, $this->filterRepl, $v['title']); $v['news'] = preg_replace($this->filterFind, $this->filterRepl, $v['news']); $v['fnews'] = preg_replace($this->filterFind, $this->filterRepl, $v['fnews']); }
$nohtml = 0; if (!$s->users[$v['user']]['perms'][$this->categoria]['usehtml'] && !$s->users[$v['user']]['perms']['admin']) {$nohtml = 1; }
$v['news'] = $this->news_parse($v['news'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$v['fnews'] = $this->news_parse($v['fnews'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$repl = array();
$repl['system:mzn2dir'] = $s->sys['sys']['dir'];
$repl['system:thispage'] = $s->req['PHP_SELF'];
$repl['news:id'] = $v['id'];
$repl['news:title'] = $v['title']; if ($s->cat[$this->categoria]['news']['cut'] && strlen($repl['news:title']) > $s->cat[$this->categoria]['news']['cut']) {$repl['news:title'] = substr($repl['news:title'], 0, intval($s->cat[$this->categoria]['news']['cut'] - 3)) ."..."; }
$repl['news:title:nocut'] = $v['title'];
$repl['news:contents'] = $v['news'];
$repl['news:full'] = $v['fnews'];
$repl['news:comments'] = $comments[$v['id']]; if ($v['data']['nc']) {$repl['news:comments'] = "-"; }
$date = $this->tpl("date"); $date = $this->parse_date($date, $v['time']);
$repl['news:date'] = $date;
$repl['date:day'] = date("d", $v['time']);
$repl['date:month'] = date("m", $v['time']);
$repl['date:year'] = date("Y", $v['time']);
$repl['date:hour'] = date("H", $v['time']);
$repl['date:minute'] = date("i", $v['time']);
$repl['date:second'] = date("s", $v['time']);
$repl['user:login'] = $v['user'];
$repl['user:name'] = $s->users[$v['user']]['name'];
$repl['user:mail'] = $s->users[$v['user']]['mail'];
$repl['user:icq'] = $s->users[$v['user']]['icq'];
$repl['user:field1'] = $s->users[$v['user']]['field1'];
$repl['user:field2'] = $s->users[$v['user']]['field2'];
$repl['user:field3'] = $s->users[$v['user']]['field3'];
$repl['user:posts'] = $s->users[$v['user']]['posts'];
if ($v['data']['f']) {$repl['news:contents'] .= $this->tpl("fnews_link", $repl); }
$final = $this->tpl("fnews", $repl);
$final = $this->parse_date_adv($final, $v['time'], "date:");
echo $final;
break;
}
}
// Aliases
function mostrar_notícia_completa() {$this->mostrar_noticia_completa(); }
function mostrar_comentarios() {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$o1 = $s->simple_string($this->ordenar_por); $o2 = $s->simple_string(substr($this->ordem, 0, 1));
if ($this->busca) {$busca = $s->regex_search($this->busca); }
if (!$this->pagina) {$this->pagina = 1; }
$ndb = array();
$i = 0; foreach ($this->dbC as $k => $v) {
if ($v['cid'] != $this->categoria || $v['nid'] != $this->noticia || $v['data']['q']) {continue; }
$k = "";
if ($o1 == "data") {$k .= $v['time']; while (strlen($k) < 20) {$k = "0". $k; } }
else if ($o1 == "usuario") {$k = $v['data']['n']; }
$k .= "|". $i;
$ndb[$k] = $v;
$i++; }
if ($o2 == "d") {krsort($ndb); }
else {ksort($ndb); }
$count = count($ndb); $page = $this->pagina; $perpage = $this->porpagina;
if ($count) {
if ($perpage == 0) {$iStart = 0; $iEnd = $count; $this->paginas = 1; }
else {
$pg_tot = 1; while ($count - $perpage > 0) {$pg_tot++; $count -= $perpage; }
if ($page > $pg_tot) {$page = $pg_tot; } if ($page < 1) {$page = 1; }
$iStart = intval(($page - 1) * $perpage); $iEnd = round($page * $perpage);
$this->paginas = $pg_tot;
}
$i = 0; foreach ($ndb as $k => $v) {
if ($i >= $iStart && $i < $iEnd) {
if ($s->sys['filter']['comments']) {$v['title'] = preg_replace($this->filterFind, $this->filterRepl, $v['title']); $v['comment'] = preg_replace($this->filterFind, $this->filterRepl, $v['comment']); }
$v['comment'] = $this->news_parse($v['comment'], 0, !$s->cat[$this->categoria]['comments']['mzncode'], !$s->cat[$this->categoria]['comments']['smilies'], 1);
$repl = array();
$repl['system:mzn2dir'] = $s->sys['sys']['dir'];
$repl['system:thispage'] = $s->req['PHP_SELF'];
$repl['comment:id'] = $v['id'];
$repl['comment:title'] = $v['title'];
$repl['comment:contents'] = $v['comment'];
$date = $this->tpl("date"); $date = $this->parse_date($date, $v['time']);
$repl['comment:date'] = $date;
$repl['comment:name'] = $v['data']['n'];
$repl['comment:mail'] = $v['data']['m'];
$repl['comment:ip'] = $v['data']['i'];
$repl['date:day'] = date("d", $v['time']);
$repl['date:month'] = date("m", $v['time']);
$repl['date:year'] = date("Y", $v['time']);
$repl['date:hour'] = date("H", $v['time']);
$repl['date:minute'] = date("i", $v['time']);
$repl['date:second'] = date("s", $v['time']);
$final = $this->tpl("comment", $repl);
$final = $this->parse_date_adv($final, $v['time'], "date:");
echo $final;
}
$i++;
}
}
else {echo "Não há comentários<br /><br />"; }
}
// Aliases
function mostrar_comentários() {$this->mostrar_comentarios(); }
function mostrar_arquivo ($link) {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$months = array("01" => "Janeiro", "02" => "Fevereiro", "03" => "Março", "04" => "Abril", "05" => "Maio", "06" => "Junho", "07" => "Julho", "08" => "Agosto", "09" => "Setembro", "10" => "Outubro", "11" => "Novembro", "12" => "Dezembro");
$dates = array();
foreach ($this->dbN as $k => $v) {
$k = date("Y-m", $v['time']);
if (!$dates[$k]) {$dates[$k] = 0; } $dates[$k]++;
}
ksort($dates);
foreach ($dates as $date => $count) {
list($year, $month) = explode("-", $date);
$repl = array();
$repl['link:href'] = str_replace("{data}", $date, $link);
$repl['link:target'] = "_self";
$repl['link:text'] = $year ." - ". $months[$month];
echo $this->tpl("link", $repl);
}
}
function mostrar_usuarios ($link) {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$users = array();
foreach ($s->users as $k => $v) {
$users[$k] = $v['name'];
}
asort($users);
foreach ($users as $id => $user) {
list($year, $month) = explode("-", $date);
$repl = array();
$repl['link:href'] = str_replace("{usuario}", $id, $link);
$repl['link:target'] = "_self";
$repl['link:text'] = $user;
echo $this->tpl("link", $repl);
}
}
// Aliases
function mostrar_usuários ($link) {$this->mostrar_usuarios($link); }
function mostrar_paginacao ($link, $tpl = 1) {
global $s, $m;
global $system_ok; if (!$system_ok) {return; }
if (!$this->pagina) {$this->pagina = 1; }
$link = str_replace("{página}", "{pagina}", $link);
if (strpos($link, "{pagina}") === FALSE || $this->paginas == 1) {return; }
$res = "";
if ($tpl == 1) {
if ($this->pagina > 3) {$res .= "<a href=\"". str_replace("{pagina}", 1, $link) ."\" title=\"Ir para a primeira página\"> « </a> "; }
if ($this->pagina > 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 1), $link) ."\" title=\"Ir para a página anterior\"> </a> "; }
if ($this->pagina > 2) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 2), $link) ."\" title=\"Ir para a página ". ($this->pagina - 2) ."\"> ". ($this->pagina - 2) ." </a> "; }
if ($this->pagina > 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 1), $link) ."\" title=\"Ir para a página ". ($this->pagina - 1) ."\"> ". ($this->pagina - 1) ." </a> "; }
$res .= "<a href=\"#\" title=\"Ir para uma página específica\" onclick=\"var page = ". $this->pagina .", pages = ". $this->paginas .", selected = 1; if (pages > 1 && page == pages) {selected = pages - 1; } else if (pages > 1) {selected = page + 1;} var go = prompt('Escolha uma página para ir.\\nDigite um número entre 1 e '+ pages, selected); if (go) {document.location = '". str_replace("{pagina}", "'+ go +'", $link) ."'; } return false; \"> <b>". $this->pagina ."</b> </a> ";
if ($this->pagina < $this->paginas) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 1), $link) ."\" title=\"Ir para a página ". ($this->pagina + 1) ."\"> ". ($this->pagina + 1) ." </a> "; }
if ($this->pagina < $this->paginas - 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 2), $link) ."\" title=\"Ir para a página ". ($this->pagina + 2) ."\"> ". ($this->pagina + 2) ." </a> "; }
if ($this->pagina < $this->paginas) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 1), $link) ."\" title=\"Ir para a próxima página\"> </a> "; }
if ($this->pagina < $this->paginas - 2) {$res .= "<a href=\"". str_replace("{pagina}", $this->paginas, $link) ."\" title=\"Ir para a última página\"> » </a>"; }
}
else if ($tpl == 2) {
if ($this->pagina > 3) {$res .= "<a href=\"". str_replace("{pagina}", 1, $link) ."\" title=\"Ir para a primeira página\"> « </a> "; }
if ($this->pagina > 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 1), $link) ."\" title=\"Ir para a página anterior\"> </a> "; }
$res .= "<a href=\"#\" title=\"Ir para uma página específica\" onclick=\"var page = ". $this->pagina .", pages = ". $this->paginas .", selected = 1; if (pages > 1 && page == pages) {selected = pages - 1; } else if (pages > 1) {selected = page + 1;} var go = prompt('Escolha uma página para ir.\\nDigite um número entre 1 e '+ pages, selected); if (go) {document.location = '". str_replace("{pagina}", "'+ go +'", $link) ."'; } return false; \"> <b>". $this->pagina ."</b> </a> ";
if ($this->pagina < $this->paginas) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 1), $link) ."\" title=\"Ir para a próxima página\"> </a> "; }
if ($this->pagina < $this->paginas - 2) {$res .= "<a href=\"". str_replace("{pagina}", $this->paginas, $link) ."\" title=\"Ir para a última página\"> » </a>"; }
}
else if ($tpl == 3) {
$res .= "<a href=\"#\" title=\"Ir para uma página específica\" onclick=\"var page = ". $this->pagina .", pages = ". $this->paginas .", selected = 1; if (pages > 1 && page == pages) {selected = pages - 1; } else if (pages > 1) {selected = page + 1;} var go = prompt('Escolha uma página para ir.\\nDigite um número entre 1 e '+ pages, selected); if (go) {document.location = '". str_replace("{pagina}", "'+ go +'", $link) ."'; } return false; \">Páginas:</a> (". $this->paginas .") ";
if ($this->pagina > 3) {$res .= "<a href=\"". str_replace("{pagina}", 1, $link) ."\" title=\"Ir para a primeira página\">« Primeira</a> ... "; }
if ($this->pagina > 2) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 2), $link) ."\" title=\"Ir para a página ". ($this->pagina - 2) ."\">". ($this->pagina - 2) ."</a> "; }
if ($this->pagina > 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 1), $link) ."\" title=\"Ir para a página ". ($this->pagina - 1) ."\">". ($this->pagina - 1) ."</a> "; }
$res .= "<b>[". $this->pagina ."]</b> ";
if ($this->pagina < $this->paginas) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 1), $link) ."\" title=\"Ir para a página ". ($this->pagina + 1) ."\">". ($this->pagina + 1) ."</a> "; }
if ($this->pagina < $this->paginas - 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 2), $link) ."\" title=\"Ir para a página ". ($this->pagina + 2) ."\">". ($this->pagina + 2) ."</a> "; }
if ($this->pagina < $this->paginas - 2) {$res .= "... <a href=\"". str_replace("{pagina}", $this->paginas, $link) ."\" title=\"Ir para a última página\">Última »</a>"; }
}
else if ($tpl == 4) {
$res .= "<select onchange=\"var page = ". $this->pagina .", pages = ". $this->paginas ."; go = this.options[this.selectedIndex].value; if (go) {document.location = '". str_replace("{pagina}", "'+ go +'", $link) ."'; } \">";
for ($i = 1; $i <= $this->paginas; $i++) {$res .= "<option value=\"". $i ."\""; if ($i == $this->pagina) {$res .= " selected"; } $res .= ">Página ". $i ."</option>"; }
$res .= "</select>";
}
else if ($tpl == 5) {
if ($this->pagina > 1) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina - 1), $link) ."\" title=\"Ir para a página ". ($this->pagina - 1) ."\">Anterior</a> "; }
else {$res .= "Anterior"; }
$res .= " | <a href=\"#\" title=\"Ir para uma página específica\" onclick=\"var page = ". $this->pagina .", pages = ". $this->paginas .", selected = 1; if (pages > 1 && page == pages) {selected = pages - 1; } else if (pages > 1) {selected = page + 1;} var go = prompt('Escolha uma página para ir.\\nDigite um número entre 1 e '+ pages, selected); if (go) {document.location = '". str_replace("{pagina}", "'+ go +'", $link) ."'; } return false; \">Página ". $this->pagina ."</a> | ";
if ($this->pagina < $this->paginas) {$res .= "<a href=\"". str_replace("{pagina}", ($this->pagina + 1), $link) ."\" title=\"Ir para a página ". ($this->pagina + 1) ."\">Próxima</a> "; }
else {$res .= "Próxima"; }
}
echo $res;
}
// Aliases
function mostrar_paginação ($link, $tpl = 1) {$this->mostrar_paginacao($link, $tpl); }
function mostrar_formulario_email ($args = "", $cancelar = "") {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
if ($args) {$args = "?". $args; }
if ($cancelar) {
if ($cancelar == "voltar") {$cancelar = "history.back(); "; }
else if ($cancelar == "fechar") {$cancelar = "window.close(); "; }
else {$cancelar = "location.href = '"+ $s->quote_safe($cancelar) +"'; "; }
}
if (!$this->noticia) {
echo "ID faltando!<br />";
}
else {
$res .= "<scr"."ipt type=\"text/javascript\" language=\"JavaScript\" src=\"". $s->sys['sys']['dir'] ."/mzn2.js\"></scr"."ipt>\n";
$res .= "<form style=\"margin:0px; \" name=\"MZn2_FormMail\" action=\"". $s->req['PHP_SELF'] . $args ."\" method=\"post\" autocomplete=\"off\" onsubmit=\"if (checkFields(this, 'mzn[from][name]', 'mzn[from][mail]:mail', 'mzn[to][name]', 'mzn[to][mail]:mail', 'mzn[subject]')) {return true; document.getElementById('btSub').disabled = '1'; } else {alert('Por favor, preencha corretamente todos os campos em negrito.'); return false; } \">\n";
$res .= " <input type=\"hidden\" name=\"mzn[id]\" value=\"". $this->noticia ."\" />\n";
$res .= " <table width=\"450\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"text-align:left; \" id=\"MZn2\">\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"222\"><b>Seu nome</b><br /><input type=\"text\" name=\"mzn[from][name]\" id=\"form_mzn[from][name]\" value=\"\" tabindex=\"1\" class=\"normal\" style=\"width:216px; \" /></td><td width=\"5\"></td><td valign=\"top\" align=\"left\" width=\"222\"><b>Seu e-mail</b><br /><input type=\"text\" name=\"mzn[from][mail]\" id=\"form_mzn[from][mail]\" value=\"\" tabindex=\"2\" class=\"normal\" style=\"width:216px; \" /></td></tr></table></td></tr>\n";
$res .= " <tr><td height=\"4\"></td></tr>\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"222\"><b>Nome do seu amigo(a)</b><br /><input type=\"text\" name=\"mzn[to][name]\" id=\"form_mzn[to][name]\" value=\"\" tabindex=\"3\" class=\"normal\" style=\"width:216px; \" /></td><td width=\"5\"></td><td valign=\"top\" align=\"left\" width=\"222\"><b>E-mail do seu amigo(a)</b><br /><input type=\"text\" name=\"mzn[to][mail]\" id=\"form_mzn[to][mail]\" value=\"\" tabindex=\"4\" class=\"normal\" style=\"width:216px; \" /></td></tr></table></td></tr>\n";
$res .= " <tr><td height=\"4\"></td></tr>\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"450\"><b>Assunto</b><br /><input type=\"text\" name=\"mzn[subject]\" id=\"form_mzn[subject]\" value=\"\" tabindex=\"5\" class=\"normal\" style=\"width:444px; \" /></td></tr></table></td></tr>\n";
$res .= " <tr><td><hr color=\"#000000\" noshade size=\"1\" /></td></tr>\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formFooter\"><tr><td valign=\"top\" align=\"right\"><button id=\"btSub\" type=\"submit\" class=\"submit\" tabindex=\"6\" accesskey=\"e\" title=\"Tecla de atalho: Alt+E\">Enviar</button>"; if ($cancelar) {$res .= " <button type=\"button\" onclick=\"". $cancelar ."\" tabindex=\"7\">Cancelar</button>"; } $res .= "</td></tr></table></td></tr>\n";
$res .= " </table>\n";
$res .= "</form>\n";
echo $res;
}
}
// Aliases
function mostrar_formulário_email($i_name, $i_value, $cancelar = "") {$this->mostrar_formulário_email($i_name, $i_value, $cancelar); }
function enviar_email () {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$id = $s->req['mzn']['id'];
if (!$s->req['mzn']['from']['name'] || !$s->req['mzn']['from']['mail'] || !$s->req['mzn']['to']['name'] || !$s->req['mzn']['to']['mail'] || !$s->req['mzn']['subject']) {
echo "Por favor preencha todos os campos em negrito!";
}
else if (!$id) {
echo "ID faltando!";
}
else {
$this->noticia = $id;
$comments = array();
foreach ($this->dbC as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q']) {continue; }
if (!$comments[$v['nid']]) {$comments[$v['nid']] = 0; }
$comments[$v['nid']] += 1;
}
$i = 0; foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['id'] != $this->noticia) {continue; }
if (!$comments[$v['id']]) {$comments[$v['id']] = 0; }
if ($s->sys['filter']['news']) {$v['title'] = preg_replace($this->filterFind, $this->filterRepl, $v['title']); $v['news'] = preg_replace($this->filterFind, $this->filterRepl, $v['news']); $v['fnews'] = preg_replace($this->filterFind, $this->filterRepl, $v['fnews']); }
$nohtml = 0; if (!$s->users[$v['user']]['perms'][$this->categoria]['usehtml'] && !$s->users[$v['user']]['perms']['admin']) {$nohtml = 1; }
$v['news'] = $this->news_parse($v['news'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$v['fnews'] = $this->news_parse($v['fnews'], $v['data']['b'], $v['data']['c'], $v['data']['s'], $nohtml);
$repl = array();
$repl['system:mzn2dir'] = $s->sys['sys']['dir'];
$repl['system:thispage'] = $s->req['PHP_SELF'];
$repl['news:id'] = $v['id'];
$repl['news:title'] = $v['title']; if ($s->cat[$this->categoria]['news']['cut'] && strlen($repl['news:title']) > $s->cat[$this->categoria]['news']['cut']) {$repl['news:title'] = substr($repl['news:title'], 0, intval($s->cat[$this->categoria]['news']['cut'] - 3)) ."..."; }
$repl['news:title:nocut'] = $v['title'];
$repl['news:contents'] = $v['news'];
$repl['news:full'] = $v['fnews'];
$repl['news:comments'] = $comments[$v['id']]; if ($v['data']['nc']) {$repl['news:comments'] = "-"; }
$date = $this->tpl("date"); $date = $this->parse_date($date, $v['time']);
$repl['news:date'] = $date;
$repl['date:day'] = date("d", $v['time']); $repl['date:month'] = date("m", $v['time']); $repl['date:year'] = date("Y", $v['time']); $repl['date:hour'] = date("H", $v['time']); $repl['date:minute'] = date("i", $v['time']); $repl['date:second'] = date("s", $v['time']);
$repl['user:login'] = $v['user'];
$repl['user:name'] = $s->users[$v['user']]['name'];
$repl['user:mail'] = $s->users[$v['user']]['mail'];
$repl['user:icq'] = $s->users[$v['user']]['icq'];
$repl['user:field1'] = $s->users[$v['user']]['field1'];
$repl['user:field2'] = $s->users[$v['user']]['field2'];
$repl['user:field3'] = $s->users[$v['user']]['field3'];
$repl['user:posts'] = $s->users[$v['user']]['posts'];
break;
}
$repl['mail:from_name'] = $s->req['mzn']['from']['name'];
$repl['mail:from_mail'] = $s->req['mzn']['from']['mail'];
$repl['mail:to_name'] = $s->req['mzn']['to']['name'];
$repl['mail:to_mail'] = $s->req['mzn']['to']['mail'];
$repl['mail:subject'] = $s->req['mzn']['subject'];
$final = $this->tpl("mailnews", $repl);
$final = $this->parse_date_adv($final, $v['time'], "date:");
if (!$s->cfg['ver']['demo']) {
$mailBody = $final;
$mailSent = @mail($s->req['mzn']['to']['name'] ." <". $s->req['mzn']['to']['mail'] .">", "[MZn²] ". $s->req['mzn']['subject'], $mailBody, "From: ". $s->req['mzn']['from']['name'] ." <". $s->req['mzn']['from']['mail'] .">\r\nContent-type: text/html");
} else {$mailSent = 1; }
if ($mailSent) {echo "O e-mail foi enviado!"; }
else {echo "Não foi possível enviar o e-mail. Tente novamente mais tarde."; }
}
}
function mostrar_formulario_comentario ($args = "") {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
if ($args) {$args = "?". $args; }
if (!$s->cat[$this->categoria]['comments']['active']) {echo "Os comentários não estão<br />ativados nesta categoria<br />"; }
else if (!$this->noticia) {
echo "<b>ID faltando!</b><br /><br />";
}
else if (!$this->verify_ip()) {
echo "<b>O seu IP foi bloqueado!</b><br /><br />";
}
else {
$ok = 0;
foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q'] || ($v['data']['t'] && $s->cfg['time'] < $v['time']) || $v['id'] != $this->noticia) {continue; }
$ok = 1; if ($v['data']['nc']) {$ok = 2; } else if ($v['data']['cx'] && $v['time'] + ($v['data']['cx'] * 86400) < $s->cfg['time']) {$ok = 3; }
}
if (!$ok) {echo "<b>ID inválido!</b><br /><br />"; }
else if ($ok == 2) {echo "A adição de comentários<br />foi bloqueada<br /><br />"; }
else if ($ok == 3) {echo "O período de adição de<br />comentários expirou<br /><br />"; }
else {
$res .= "<scr"."ipt type=\"text/javascript\" language=\"JavaScript\" src=\"". $s->sys['sys']['dir'] ."/mzn2.js\"></scr"."ipt>\n";
$res .= "<form style=\"margin:0px; \" name=\"MZn2_AddComment\" action=\"". $s->req['PHP_SELF'] . $args ."\" method=\"post\" autocomplete=\"off\" onsubmit=\"if (checkFields(this, 'mzn[n]'"; if ($s->cat[$this->categoria]['comments']['req_mail']) {$res .= ", 'mzn[m]:mail'"; } if ($s->cat[$this->categoria]['comments']['req_title']) {$res .= ", 'mzn[title]'"; } $res .= ", 'mzn[comment]')) {return true; document.getElementById('btSub').disabled = '1'; } else {alert('Por favor, preencha corretamente todos os campos em negrito.'); return false; } \">\n";
if ($args) {$res .= " <input type=\"hidden\" name=\"args\" value=\"". $s->quote_safe($args) ."\" />\n"; }
$res .= " <input type=\"hidden\" name=\"mzn[id]\" value=\"". $this->noticia ."\" />\n";
$res .= " <input type=\"hidden\" name=\"mzn[comment]\" value=\"\" />\n";
$res .= " <table width=\"450\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"text-align:left; \">\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"222\"><b>Seu nome</b><br /><input type=\"text\" name=\"mzn[n]\" id=\"form_mzn[n]\" value=\"\" tabindex=\"1\" class=\"normal\" style=\"width:218px; \" onchange=\"form_changed = 1; \" /></td><td width=\"5\"><img src=\"". $s->sys['sys']['dir'] ."/img/_blank.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td><td valign=\"top\" align=\"left\" width=\"222\">"; if ($s->cat[$this->categoria]['comments']['req_mail']) {$res .= "<b>Seu e-mail</b>"; } else {$res .= "Seu e-mail"; } $res .= "<br /><input type=\"text\" name=\"mzn[m]\" id=\"form_mzn[m]\" value=\"\" tabindex=\"2\" class=\"normal\" style=\"width:218px; \" onchange=\"form_changed = 1; \" /></td></tr></table></td></tr>\n";
$res .= " <tr><td height=\"4\"></td></tr>\n";
if ($s->cat[$this->categoria]['comments']['field1'] || $s->cat[$this->categoria]['comments']['field2']) {
$width = ($s->cat[$this->categoria]['comments']['field1'] && $s->cat[$this->categoria]['comments']['field2'])? 222 : 450;
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr>";
if ($s->cat[$this->categoria]['comments']['field1']) {$res .= "<td valign=\"top\" align=\"left\" width=\"". $width ."\">". $s->cat[$this->categoria]['comments']['field1'] ."<br /><input type=\"text\" name=\"mzn[f1]\" id=\"form_mzn[f1]\" value=\"\" tabindex=\"3\" class=\"normal\" style=\"width:". ($width - 4) ."px; \" onchange=\"form_changed = 1; \" /></td>"; }
if ($s->cat[$this->categoria]['comments']['field1'] && $s->cat[$this->categoria]['comments']['field2']) {$res .= "<td width=\"5\"><img src=\"". $s->sys['sys']['dir'] ."/img/_blank.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td>"; }
if ($s->cat[$this->categoria]['comments']['field2']) {$res .= "<td valign=\"top\" align=\"left\" width=\"". $width ."\">". $s->cat[$this->categoria]['comments']['field2'] ."<br /><input type=\"text\" name=\"mzn[f2]\" id=\"form_mzn[f2]\" value=\"\" tabindex=\"4\" class=\"normal\" style=\"width:". ($width - 4) ."px; \" onchange=\"form_changed = 1; \" /></td>"; }
$res .= "</tr></table></td></tr>\n";
$res .= " <tr><td height=\"4\"></td></tr>\n";
}
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"450\">"; if ($s->cat[$this->categoria]['comments']['req_title']) {$res .= "<b>Título</b>"; } else {$res .= "Título"; } $res .= "<br /><input type=\"text\" name=\"mzn[title]\" id=\"form_mzn[title]\" value=\"\""; if ($s->cat[$this->categoria]['comments']['limit_title']) {$res .= " maxlength=\"". $s->cat[$this->categoria]['comments']['limit_title'] ."\""; } $res .=" tabindex=\"5\" class=\"normal\" style=\"width:446px; \" onchange=\"form_changed = 1; \" /></td></tr></table></td></tr>\n";
$res .= " <tr><td height=\"4\"></td></tr>\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formItem\"><tr><td valign=\"top\" align=\"left\" width=\"505\"><iframe src=\"". $s->sys['sys']['dir'] ."/wait.php?sleep=1&g=". urlencode($s->sys['sys']['dir'] ."/index.php?sec=edv&act=comments&limit=". $s->cat[$this->categoria]['comments']['limit_comment'] ."&mznCode=". $s->cat[$this->categoria]['comments']['mzncode'] ."&smilies=". $s->cat[$this->categoria]['comments']['smilies']) ."\" tabindex=\"6\" name=\"edv_comment\" scrolling=\"no\" width=\"450\" height=\"172\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"no\"></iframe></td></tr></table></td></tr>\n";
$res .= " <tr><td><hr color=\"#000000\" noshade size=\"1\" /></td></tr>\n";
$res .= " <tr><td valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"formFooter\"><tr><td valign=\"top\" align=\"right\"><button id=\"btSub\" type=\"submit\" class=\"submit\" tabindex=\"7\" accesskey=\"a\" title=\"Tecla de atalho: Alt+A\">Adicionar</button></td></tr></table></td></tr>\n";
$res .= " </table>\n";
$res .= "</form>\n";
echo $res;
}
}
}
// Aliases
function mostrar_formulário_comentário ($args = "") {$this->mostrar_formulario_comentario($args); }
function adicionar_comentario () {
global $s, $m;
global $system_ok; if (!$system_ok) {echo $this->msg; return; }
$id = $s->req['mzn']['id'];
if (!$s->cat[$this->categoria]['comments']['active']) {echo "Os comentários não estão<br />ativados nesta categoria<br />"; }
else if (!$id) {
echo "ID faltando!<br /><br />";
}
else if (!$this->verify_ip()) {
echo "<b>O seu IP foi bloqueado!</b><br /><br />";
}
else if (!$s->req['HTTP_REFERER']) {echo "Referência inválida!<br /><br />"; }
else {
$ok = 0; $login_ok = 0;
if ($s->req['mzn']['login_usr'] && $s->req['mzn']['login_pwd'] && !$this->test_login($s->users[$s->req['mzn']['login_usr']]['pwd'], $s->req['mzn']['login_pwd'])) {$login_ok = 1; }
foreach ($this->dbN as $k => $v) {
if ($v['cid'] != $this->categoria || $v['data']['q'] || ($v['data']['t'] && $s->cfg['time'] < $v['time']) || $v['id'] != $id) {continue; }
$ok = 1; if ($v['data']['nc']) {$ok = 2; } else if ($v['data']['cx'] && $v['time'] + ($v['data']['cx'] * 86400) < $s->cfg['time']) {$ok = 3; }
}
if (!$ok) {echo "<b>ID inválido!</b><br /><br />"; }
else if ($ok == 2) {echo "A adição de comentários<br />foi bloqueada<br /><br />"; }
else if ($ok == 3) {echo "O período de adição de<br />comentários expirou<br /><br />"; }
else if ($s->req['last'] && ($s->req['last'] + $s->sys['visitor']['floodint']) > $s->cfg['time']) {echo "Por favor aguarde mais ". (($s->req['last'] + $s->sys['visitor']['floodint']) - $s->cfg['time']) ." segundos antes de postar outro comentário.<br />"; }
else if (!$s->req['mzn']['n'] || (!$s->req['mzn']['m'] && $s->cat[$this->categoria]['comments']['req_mail']) || (!$s->req['mzn']['title'] && $s->cat[$this->categoria]['comments']['req_title']) || !$s->req['mzn']['comment']) {echo "Preencha todos os campos em negrito!<br />"; }
else if (!$this->verify_name($s->req['mzn']['n']) && !$login_ok) {echo "<b>Nome reservado!</b><br /><br />Você só pode usar este nome se for este usuário ou um administrador.<br /><br /><a href=\"#\" onclick=\"window.open('". $s->sys['sys']['dir'] ."/index.php?sec=login&act=popup&form=MZn2_AddComment&ufield=". urlencode("mzn[login_usr]") ."&pfield=". urlencode("mzn[login_pwd]") ."', 'MZn2login', 'width=400,height=155,top=20,left=20,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'); return false; \">Clique aqui para efetuar login.</a><form name=\"MZn2_AddComment\" action=\"". $s->req['PHP_SELF'] . $s->req['args'] ."\" method=\"post\"><input type=\"hidden\" name=\"mzn[back]\" value=\"". $s->quote_safe($s->req['HTTP_REFERER']) ."\" /><input type=\"hidden\" name=\"mzn[login_usr]\" value=\"\" /><input type=\"hidden\" name=\"mzn[login_pwd]\" value=\"\" /><input type=\"hidden\" name=\"mzn[id]\" value=\"". $s->quote_safe($id) ."\" /><input type=\"hidden\" name=\"mzn[n]\" value=\"". $s->quote_safe($s->req['mzn']['n']) ."\" /><input type=\"hidden\" name=\"mzn[m]\" value=\"". $s->quote_safe($s->req['mzn']['m']) ."\" /><input type=\"hidden\" name=\"mzn[f1]\" value=\"". $s->quote_safe($s->req['mzn']['f1']) ."\" /><input type=\"hidden\" name=\"mzn[f2]\" value=\"". $s->quote_safe($s->req['mzn']['f2']) ."\" /><input type=\"hidden\" name=\"mzn[title]\" value=\"". $s->quote_safe($s->req['mzn']['title']) ."\" /><input type=\"hidden\" name=\"mzn[comment]\" value=\"". $s->quote_safe($s->req['mzn']['comment']) ."\" /></form>"; }
else {
if (!$s->cfg['ver']['demo']) {
$nl = array();
$nl['id'] = substr(md5(rand()*time()), 0, 10);
$nl['cid'] = $this->categoria;
$nl['nid'] = $id;
$nl['time'] = $s->cfg['time'];
$nl['title'] = $s->req['mzn']['title']; if ($s->cat[$this->categoria]['comments']['limit_title'] && strlen($s->req['mzn']['title']) > $s->cat[$this->categoria]['comments']['limit_title']) {$s->req['mzn']['title'] = substr($s->req['mzn']['title'], 0, $s->cat[$this->categoria]['comments']['limit_title']); }
$nl['comment'] = $s->req['mzn']['comment']; if ($s->cat[$this->categoria]['comments']['limit_comment'] && strlen($s->req['mzn']['comment']) > $s->cat[$this->categoria]['comments']['limit_comment']) {$s->req['mzn']['comment'] = substr($s->req['mzn']['comment'], 0, $s->cat[$this->categoria]['comments']['limit_comment']); }
$nl['data']['n'] = $s->req['mzn']['n'];
$nl['data']['m'] = $s->req['mzn']['m'];
$nl['data']['i'] = $this->ip;
$nl['data']['f1'] = $s->req['mzn']['f1'];
$nl['data']['f2'] = $s->req['mzn']['f2'];
$nl['data']['q'] = $s->cat[$this->categoria]['comments']['queue'];
$db = $s->db_table_open($s->cfg['file']['comments']);
$db['data'][count($db['data'])] = $nl;
$s->db_table_save($s->cfg['file']['comments'], $db);
}
if (!$s->req['mzn']['back']) {$s->req['mzn']['back'] = $s->req['HTTP_REFERER']; }
echo "<scr"."ipt type=\"text/javascript\" language=\"JavaScript\">document.cookie = \"last=". $s->cfg['time'] ."; expires=Fri, 31 Dec 2004 23:59:59 UTC\"; location.replace(\"". addslashes($s->req['mzn']['back'] ."#Comentario_". $nl['id']) ."\"); </scr"."ipt>";
}
}
}
}
?>