-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforum_topics.php
executable file
·254 lines (192 loc) · 7.77 KB
/
forum_topics.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
<?php
/* I codici qui inseriti sono proprietà di
* Francesco Stasi, pertanto ne è vietata la
* vendita e la cessione a terzi senza previa
* autorizzazione dell' autore.
*/
require_once("config.php");
require_once("libs/common.php");
require_once("libs/forum_lib.php");
require_once("libs/character_lib.php");
if(!isset($_SESSION))
{
session_start();
}
logged();
$MyChar_obj=new Character($_SESSION['char_id']);
$MyChar_obj->parseFromDb();
$_SESSION['modlevel']=$MyChar_obj->Account()->getModLevel();
$canAdmin=false;
if ($_SESSION['modlevel'] >= $acc_admin_forumtopics_required)
$canAdmin=true;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Francesco Stasi"/>
<title>Forum</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
$(document).ready(function(){
$(".forum_table").on('click', "span.admin_gear", function(){
$(".dialog_f").dialog( "close" )
$(".dialog_f").dialog( "destroy" );
var pid=$(this).attr("pid");
var newDialog=$('<div class="dialog_f" title="Gestione Topics">Topic: '+pid+
'<br /><a class="ajaxReq" href="forum_do.php?post_id='+pid+'&action=stick">Rendi Importante</a>'+
'<br /><a class="ajaxReq" href="forum_do.php?post_id='+pid+'&action=unstick">Togli Importante</a>'+
'<br /><a class="ajaxReq" href="forum_do.php?post_id='+pid+'&action=lock">Blocca inserimenti</a>'+
'<br /><a class="ajaxReq" href="forum_do.php?post_id='+pid+'&action=unlock">Sblocca inserimenti</a>'+
'<br /><a class="post_del" href="forum_newpostUW.php?del='+pid+'">Cancella Topic</a>'+
'<div class="ajaxResult"></div>'+
'</div>');
$(newDialog).dialog({ hide: 'fade',
show: 'fade',
open: function(event, ui) {
$(".post_del").click(function(){
url=$(this).attr('href');
if(confirm('Sei Sicuro di voler cancellare questo Topic ed i relativi post?')){
$.get(url,function(data){
//alert($(data).filter('span#deletedpost').html());
$(data).filter('span#deletedtopic').each(function(){
$('#'+$(this).html()).fadeOut().remove();
$(".ajaxResult").html("Topic Cancellato.");
});
});
}
return false;
});
$(".ajaxReq").click(function(event){
$.post(this.href, function(data){
$(data).filter('span#symbol_lock').each(function(){
$("#l_"+pid+".symbol_lock").empty();
$("#l_"+pid+".symbol_lock").append($(this).html());
});
$(data).filter('span#symbol_stick').each(function(){
$("#s_"+pid+".symbol_stick").empty();
$("#s_"+pid+".symbol_stick").append($(this).html());
});
$(".ajaxResult").html(data);
});
return false;
});
}
});
});
$("#reply_box").on('submit', "#form_postForum", function(){
rowArr = $(this).serializeArray();
$.post($(this).attr("action"),rowArr,function(data2){
$('.forum_table').append(data2);
$('#message').val("");
$('#newTopicTitle').val("");
$("#reply_box").fadeOut();
});
return false;
});
$("#reply_box").load("forum_newpostUW.php?b=<?=$_REQUEST['b']?>");
$("#openNew").click(function(){
$("#reply_box").fadeToggle('slow',function(){
$('#newTopicTitle').focus();
});
$('#content').animate({scrollTop: $("#reply_box").offset().top},'slow');
return false;
});
});
</script>
</head>
<body class="forum">
<div class="centertxt forum_spacer"><h2><a href="forum_boards.php"><?=$forum?></a></h2>
<?php
if (!isset($_REQUEST['b']) || $_REQUEST['b']=='' ){
echo "<br />Devi specificare la board";
exit();
}
$ForumBoard=new ForumBoard(null,$_REQUEST['b']);
$ForumBoard->checkExists();
$start_pag=0;
if ($_REQUEST['p']!='' && $_REQUEST['p']>0){
$start_pag=$_REQUEST['p']*($topics_per_pag);
}
if (!$ForumBoard->readTopics($MyChar_obj,null,true,false,$start_pag,$topics_per_pag))
echo "Accesso Negato";
$canAdmin=false;
if ($_SESSION['modlevel'] >= $acc_admin_forumtopics_required)
$canAdmin=true;
$pathT="<a href=\"forum_boards.php\">$forum</a> / {$ForumBoard->getName()}";
?>
</div>
<div class="forum_postBoxW">
<?php echo $pathT; ?>
</div>
<div class="forum_postBoxW">
<a id="openNew" href="#"><img src="images/icons/document.png" border="0" />Nuovo Topic</a>
</div>
<table class="forum_table clearborder panel_bg">
<tr class="dark_bg clearborder">
<th width="300">Oggetto</td>
<th width="200">Autore</td>
<th width="100">Risposte</td>
<th width="200">Ultima Risposta</td>
</tr>
<?php
foreach($ForumBoard->getTopics() as $key=>$value){
$value->loadChildren(true);
$value->countChildren();
$lastChild=$value->getLastChild();
$lastRpl="-";
foreach($value->getLastChild() as $k=>$v){
$tmpChar=new Character(null,$v->getAuthorName());
$lastRpl=$tmpChar->getCharNameLink()."<br />il ".itaTime($v->getDate());
}
$sticked="";
if($value->getSticky()==1){
$sticked="<img src=\"images/icons/megaphone.png\" border=\"0\" />";
}
$locked="";
if($value->getLocked()==1){
$locked="<img src=\"images/icons/lock-closed.png\" border=\"0\" />";
}
$admOpt="";
if($canAdmin){
$admOpt="<span class=\"admin_gear\" pid=\"{$value->getId()}\"><img src=\"images/icons/gear-gold.png\" border=\"0\" /></span>";
}
$recent="";
if($value->isRecent()){
$recent="<span class=\"pm_counterW floatleft\"><div class=\"pm_counter\">!</div></span>";
}
$tmpChar2=new Character(null,$value->getAuthorName());
echo "<tr id=\"forumTID_{$value->getId()}\">
<td>$recent $admOpt <span id=\"l_{$value->getId()}\" class=\"symbol_lock\">$locked</span> <span id=\"s_{$value->getId()}\" class=\"symbol_stick\">$sticked</span> <a href=\"forum_posts.php?f={$value->getId()}&b={$value->getBoard()}\">{$value->getTitle()}</a></td>
<td>{$tmpChar2->getCharNameLink()}<br />il ".itaTime($value->getDate())."</td>
<td>{$value->getNumChild()}</td>
<td>$lastRpl</td>
</tr>";
}
?>
</table>
<div id="reply_box" style="display:none;width:85%;margin:0 auto;"></div>
<table width="600" border="0" class="center" cellpadding="0" cellspacing="0">
<tr>
<td>Page:
<?php
$ForumBoard->countTopics();
//echo $ForumBoard->getNumTopics();
$count_pag=$ForumBoard->getNumTopics()/$topics_per_pag;
$n_pages=ceil($count_pag);
for ($i=0;$i<$n_pages;$i++){
$curpage=$i+1;
if ($i==$start_pag/$posts_per_pag){
echo "[$curpage]";
}else{
echo "<a href=\"".$_SERVER['PHP_SELF']."?p=$i&b={$_REQUEST['b']}\">$curpage</a> ";
}
}
?></td>
</tr>
</table>
<div id="dialog" title="Inserisci nuovo Topic" style="diplay:none"></div>
</body>
</html>