simpledecision /modules/forum/index.php

Language PHP Lines 278
MD5 Hash 2b76abd0810d31703f52339dcafb4a94 Estimated Cost $6,064 (why?)
Repository https://bitbucket.org/ssimpledecision/simpledecision.git View Raw File View Project SPDX
  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
<? include "../../inc/header_m.php";?>
<?
$searchinmodul=$_POST['searchinmodul'];
if (!empty($searchinmodul)){
	$searchinmodul=explode(' ', $searchinmodul);
	foreach ($searchinmodul as $key => $value) {
		$searchinmodules.="or UPPER(title) LIKE '%".strtoupper($value)."%' ";
		$searchinmodules.="or UPPER(text) LIKE '%".strtoupper($value)."%' ";
	}
	$searchinmodules=' ('.substr($searchinmodules, 2).') and ';
}
mysql_query("delete from {$pref}db_{$modul}_cat where status=-1");
mysql_query("delete from {$pref}db_{$modul}_th where status=-1");
mysql_query("delete from {$pref}db_{$modul} where status=-1");
$back_link=getenv("HTTP_REFERER");
if (!$back_link){
	$back = '';
}
else{
	$back = '<a href="'.$back_link.'">Вернуться назад</a>';
}
$back = '<article class="breadcrumbs"><a href="index.php">Корень</a>';
if (!empty($_GET['id_cat'])){
	$sql= mysql_query("select * from {$pref}db_{$modul}_cat where id='{$_GET['id_cat']}'");
	$inf=mysql_fetch_array($sql);
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_cat='.$_GET['id_cat'].'">'.$inf['name'].'</a>';
}
if (!empty($_GET['id_th'])){
	$sql= mysql_query("select * from {$pref}db_{$modul}_cat where id='{$_GET['id_th']}'");
	$inf=mysql_fetch_array($sql);
	$sql1= mysql_query("select * from {$pref}db_{$modul}_cat where id='{$inf['pid']}'");
	$inf1=mysql_fetch_array($sql1);
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_cat='.$inf1['id'].'">'.$inf1['name'].'</a>';
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_th='.$_GET['id_th'].'">'.$inf['name'].'</a>';
}
if (!empty($_GET['id_material'])){
	$sql= mysql_query("select * from {$pref}db_{$modul}_th where id='{$_GET['id_material']}'");
	$inf=mysql_fetch_array($sql);
	$sql1= mysql_query("select * from {$pref}db_{$modul}_cat where id='{$inf['pid']}'");
	$inf1=mysql_fetch_array($sql1);
	$sql2= mysql_query("select * from {$pref}db_{$modul}_cat where id='{$inf1['pid']}'");
	$inf2=mysql_fetch_array($sql2);
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_cat='.$inf2['id'].'">'.$inf2['name'].'</a>';
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_th='.$inf1['id'].'">'.$inf1['name'].'</a>';
	$back .= '<div class="breadcrumb_divider"></div><a href="index.php?id_material='.$_GET['id_material'].'">'.$inf['name'].'</a>';
}
$back.='</article>&nbsp;';
$del = $_POST['list'];
$sor = $_POST['sor'];
$del2 = $_POST['list2'];
$sor2 = $_POST['sor2'];
$del3 = $_POST['list3'];
$sor3 = $_POST['sor3'];
if (isset($del)) 
	foreach ($del as &$delv)
		{
		mysql_query("delete from {$pref}db_{$modul}_cat where id={$delv}");
		// mysql_query("delete from {$pref}db_gallery where pid={$delv}");
		}
if (isset($sor)) 
	foreach ($sor as $sork=>$sorv)
		{
		mysql_query("update {$pref}db_{$modul}_cat set sort={$sorv} where id={$sork}");
		}
if (isset($del2)) 
	foreach ($del2 as &$delv2)
		{
		mysql_query("delete from {$pref}db_{$modul}_th where id={$delv2}");
		}
if (isset($sor2)) 
	foreach ($sor2 as $sork2=>$sorv2)
		{
		mysql_query("update {$pref}db_{$modul}_th set sort={$sorv2} where id={$sork2}");
		}
if (isset($del3)) 
	foreach ($del3 as &$delv3)
		{
		mysql_query("delete from {$pref}db_{$modul} where id={$delv3}");
		}
if (isset($sor3)) 
	foreach ($sor3 as $sork3=>$sorv3)
		{
		mysql_query("update {$pref}db_{$modul} set sort={$sorv3} where id={$sork3}");
		}

if (isset($_GET['sort'])) $_SESSION['sort'] = $_GET['sort'];
if (isset($_SESSION['sort'])) $sort = $_SESSION['sort'];
if (strpos($mod_ver,substr($sort,0,2))===false)
$sort = 'sort,id';
mysql_query("delete from {$pref}db_gallery_cat where status=-1");
mysql_query("delete from {$pref}db_gallery where status=-1");
$lim=30;
if (isset($_GET['p'])) $p=$_GET['p']; else {$p=1;$_GET['p']=1;}
$start=$p*$lim-$lim;

if (isset($_GET['id_material'])||isset($_POST['id_material'])){
	if (!empty($_GET['id_material'])) $id =$_GET['id_material'];	
	if (!empty($_POST['id_material'])) $id =$_POST['id_material'];
	$query=mysql_query("select * from {$pref}db_{$modul} where {$searchinmodules} pid='{$id}' order by {$sort} limit $start,$lim");
	$total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where  {$searchinmodules}  pid='{$id}' "));
	$m_title="Сообщения";
	$body="
<table class='tablesorter' cellspacing='0'>
	<thead> 
		<tr>
			<th>ID</th>
			<th>Текст</th>
			<th>Сортировка</th>
			<th>Статус</th>
			<td>Удалить<input type='checkbox' class='selectdelete'></td>
	</tr>	
	</thead> 	
	<tbody> 
";
	while ($res=mysql_fetch_array($query)){
		$text = strip_tags(mb_substr($res['text'], 0,50),' ');
		$body.="
			<tr>
				<td><a href='edit.materials.php?id_material={$res['id']}'>{$res['id']}</td>
				<td><a href='edit.materials.php?id_material={$res['id']}'>{$text}</td>
				<td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor3[{$res['id']}]' value='{$res['sort']}' /></td>
				<td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}-{$res['id']}-{$res['status']}' >
				<img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
				<td><input type='checkbox' onclick='check();' name='list3[]' class='listdelete' value='{$res['id']}' /></td>
			</tr>";
	}
$body.="
	</tbody> 
</table>
";
}
elseif (isset($_GET['id_th'])||isset($_POST['id_th'])){
	if (!empty($_GET['id_th'])) $id_th =$_GET['id_th'];	
	if (!empty($_POST['id_th'])) $id_th =$_POST['id_th'];
	$query=mysql_query("select * from {$pref}db_{$modul}_th where pid='{$id_th}' order by {$sort} limit $start,$lim");
	$total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul}_th where pid='{$id_th}' "));
	$m_title="Темы";
	$body="
<table class='tablesorter' cellspacing='0'>
	<thead> 
		<tr>
			<th>ID</th>
			<th>Название</th>
			<th>Сортировка</th>
			<th>Статус</th>
			<th>Редактировать</th>
			<td>Удалить<input type='checkbox' class='selectdelete'></td>
	</tr>	
	</thead> 	
	<tbody> 
";
	while ($res=mysql_fetch_array($query)){
		$body.="
			<tr>
				<td><a href='index.php?id_material={$res['id']}'>{$res['id']}</td>
				<td><a href='index.php?id_material={$res['id']}'>{$res['name']}</td>
				<td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor2[{$res['id']}]' value='{$res['sort']}' /></td>
				<td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}_th-{$res['id']}-{$res['status']}' >
				<img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
				<td><a href='edit.th.php?id_material={$res['id']}'><img src='{$pt}{$tpl_admin}/images/icn_edit.png' /></td>
				<td><input type='checkbox' onclick='check();' name='list2[]' class='listdelete' value='{$res['id']}' /></td>
			</tr>";
	}
$body.="
	</tbody> 
</table>
";
}

elseif (isset($_GET['id_cat'])||isset($_POST['id_cat'])){
	if (!empty($_GET['id_cat'])) $id_cat =$_GET['id_cat'];	
	if (!empty($_POST['id_cat'])) $id_cat =$_POST['id_cat'];
	$query=mysql_query("select * from {$pref}db_{$modul}_cat where pid='{$id_cat}' order by {$sort} limit $start,$lim");
	$total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul}_cat where pid='{$id_cat}' "));
	$m_title="Форумы";
	$body="
<table class='tablesorter' cellspacing='0'>
	<thead> 
		<tr>
			<th>ID</th>
			<th>Название</th>
			<th>Сортировка</th>
			<th>Статус</th>
			<th>Редактировать</th>
			<td>Удалить<input type='checkbox' class='selectdelete'></td>
	</tr>	
	</thead> 	
	<tbody> 
";
	while ($res=mysql_fetch_array($query)){
		$body.="
			<tr>
				<td><a href='index.php?id_th={$res['id']}'>{$res['id']}</td>
				<td><a href='index.php?id_th={$res['id']}'>{$res['name']}</td>
				<td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor[{$res['id']}]' value='{$res['sort']}' /></td>
				<td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}_cat-{$res['id']}-{$res['status']}' >
				<img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
				<td><a href='edit.cat.php?id_material={$res['id']}'><img src='{$pt}{$tpl_admin}/images/icn_edit.png' /></td>
				<td><input type='checkbox' onclick='check();' name='list[]' class='listdelete' value='{$res['id']}' /></td>
			</tr>";
	}
$body.="
	</tbody> 
</table>
";
}
else {
	$query=mysql_query("select * from {$pref}db_{$modul}_cat where pid=0 order by {$sort} limit $start,$lim");
	$total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul}_cat where pid=0 "));
	$m_title="Категории";
	$body="
<table class='tablesorter' cellspacing='0'>
	<thead> 
		<tr>
			<th>ID</th>
			<th>Название</th>
			<th>Сортировка</th>
			<th>Статус</th>
			<th>Редактировать</th>
			<td>Удалить<input type='checkbox' class='selectdelete'></td>
	</tr>	
	</thead> 	
	<tbody> 
";
	while ($res=mysql_fetch_array($query)){
		$body.="
			<tr>
				<td><a href='index.php?id_cat={$res['id']}'>{$res['id']}</td>
				<td><a href='index.php?id_cat={$res['id']}'>{$res['name']}</td>
				<td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor[{$res['id']}]' value='{$res['sort']}' /></td>
				<td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}_cat-{$res['id']}-{$res['status']}' >
				<img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
				<td><a href='edit.cat.php?id_material={$res['id']}'><img src='{$pt}{$tpl_admin}/images/icn_edit.png' /></td>
				<td><input type='checkbox' onclick='check();' name='list[]' class='listdelete' value='{$res['id']}' /></td>
			</tr>";
	}
	$body.="
	</tbody> 
</table>
	";
}


?>
<script>
$(document).ready(function(){
$('.modulForm').submit(function(){
	if (!confirm("Уверены, что хотите внести изменения?"))
		return false;
})
});
</script>

<form method='POST' acction='' class='modulForm' >
<? if (isset($_POST['sf'])){?><h4 class="alert_success">Сохранено</h4><?}?>
<?=$back?>
<article class="module width_full">
<header><h3 class="tabs_involved"><?=$m_title?></h3>
		<!-- <ul class="tabs">
   			<li><a href="#tab1">Список</a></li>
		</ul> -->
</header>
		<div class="tab_container">
			<div id="tab1" class="tab_content">
<?=$body?>
</div></div>
<footer>
				<div class="submit_link fl">
					<? paging_m($total,$lim,$p);?>
				</div>
				<div class="submit_link">
					<input type='submit' value='Сохранить' name='sf' />
				</div>
			</footer>
</article>
</form>

<? include "../../inc/footer_m.php"; ?>
Back to Top