-
Notifications
You must be signed in to change notification settings - Fork 2
/
bbsal.php
504 lines (442 loc) · 16.8 KB
/
bbsal.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
<?php
require("www2-funcs.php");
login_init();
assert_login();
$hostname=bbs_sysconf_str("MYSQLHOST");
$username=bbs_sysconf_str("MYSQLUSER");
$password=bbs_sysconf_str("MYSQLPASSWORD");
$dbname=bbs_sysconf_str("MYSQLSMSDATABASE");
function al_print_form($al){
?>
<table border="0">
<tr><td>姓名:</td><td><input name="t_name" maxlength=13 size=13 value=<?php echo htmlspecialchars($al[2]);?>></td></tr>
<tr><td>分组:</td><td><input name="t_group" maxlength=13 size=13 value=<?php echo htmlspecialchars($al[15]);?>></td></tr>
<tr><td>bbsid:</td><td><input name="t_bbsid" maxlength=13 size=13 value=<?php echo htmlspecialchars($al[3]);?>></td></tr>
<tr><td>学校:</td><td><input name="t_school" size=50 value=<?php echo htmlspecialchars($al[4]);?>></td></tr>
<tr><td>邮政编码:</td><td><input name="t_zipcode" maxlength=6 size=6 value=<?php echo htmlspecialchars($al[5]);?>></td></tr>
<tr><td>家庭住址:</td><td><input name="t_homeaddr" size=50 value=<?php echo htmlspecialchars($al[6]);?>></td></tr>
<tr><td>工作地址:</td><td><input name="t_companyaddr" size=50 value=<?php echo htmlspecialchars($al[7]);?>></td></tr>
<tr><td>家庭电话:</td><td><input name="t_tel_h" maxlength=20 size=20 value=<?php echo htmlspecialchars($al[8]);?>></td></tr>
<tr><td>工作电话:</td><td><input name="t_tel_o" maxlength=20 size=20 value=<?php echo htmlspecialchars($al[9]);?>></td></tr>
<tr><td>手机号码:</td><td><input name="t_mobile" maxlength=13 size=13 value=<?php echo htmlspecialchars($al[10]);?>></td></tr>
<tr><td>email:</td><td><input name="t_email" maxlength=30 size=30 value=<?php echo htmlspecialchars($al[11]);?>></td></tr>
<tr><td>qq:</td><td><input name="t_qq" maxlength=10 size=10 value=<?php echo htmlspecialchars($al[12]);?>></td></tr>
<tr><td>生日:</td><td><input name="t_birth_year" maxlength=4 size=4 value=<?php echo substr($al[13],0,4);?>>年<input name="t_birth_month" maxlength=2 size=2 value=<?php echo substr($al[13],5,2);?>>月<input name="t_birth_day" maxlength=2 size=2 value=<?php echo substr($al[13],8,2);?>>日</td></tr>
<tr><td>备注:</td><td><input name="t_memo" size=50 value=<?php echo htmlspecialchars($al[14]);?>></td></tr>
</table>
<center>
<input type=submit name=submit value="提交">
<input type=reset name=reset value="重置">
</center>
</form>
<?php
}
if( $_GET["start"] ){
$startnum = $_GET["start"];
}else if( $_POST["start"] ){
$startnum = $_POST["start"];
}else
$startnum = 0;
settype($startnum,"integer");
if( $_GET["count"] ){
$count = $_GET["count"];
}else if( $_POST["count"] ){
$count = $_POST["count"];
}else
$count = 10;
settype($count,"integer");
if( $_GET["desc"] ){
$desc = $_GET["desc"];
}else if( $_POST["desc"] ){
$desc = $_POST["desc"];
}else
$desc = 0;
settype($desc, "integer");
if($desc == 1)
$descstr="DESC";
else
$descstr="ASC";
if( $_GET["order"] ){
$order = $_GET["order"];
}else if( $_POST["order"] ){
$order = $_POST["order"];
}
if( $order != "bbsid" && $order != "name" )
$order="groupname";
$db = mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($dbname, $db) or die(mysql_error());
if( $_GET["action"] ){
$action = $_GET["action"];
}
if(isset($action) && $action == "del"){
if( $_GET["id"] ){
$id = $_GET["id"];
}
else{
html_error_quit("参数错误1");
}
settype($id, "integer");
if($id < 0)
html_error_quit("参数错误2");
$sqlstr = "DELETE FROM addr WHERE userid=\"".$currentuser["userid"]."\" AND id=".$id;
$result = mysql_query($sqlstr) or die(mysql_error());
}else if(isset($action) && $action=="detail"){
if( $_GET["id"] ){
$id = $_GET["id"];
}
else{
html_error_quit("参数错误1");
}
settype($id, "integer");
if($id < 0)
html_error_quit("参数错误2");
$sqlstr = "SELECT * FROM addr WHERE userid=\"".$currentuser["userid"]."\" AND id=".$id;
$result = mysql_query($sqlstr) or die(mysql_error());
if( ! $result ){
html_error_quit("数据错误");
}
$row = mysql_fetch_row($result);
if( ! $row )
html_error_quit("数据错误1");
page_header("通讯录条目显示");
?>
<a href="javascript:location.reload()">刷新</a>
<hr class=default>
<table border="1" width="613" align="center" cellpadding="0" cellspacing="0">
<tr><td>姓名</td><td><?php echo htmlspecialchars($row[2]);?></td></tr>
<tr><td>bbsid</td><td><?php echo htmlspecialchars($row[3]);?></td></tr>
<tr><td>分组</td><td><?php echo htmlspecialchars($row[15]);?></td></tr>
<tr><td>生日</td><td><?php echo htmlspecialchars($row[13]);?></td></tr>
<tr><td>学校</td><td><?php echo htmlspecialchars($row[4]);?></td></tr>
<tr><td>邮政编码</td><td><?php echo htmlspecialchars($row[5]);?></td></tr>
<tr><td>家庭地址</td><td><?php echo htmlspecialchars($row[6]);?></td></tr>
<tr><td>家庭电话</td><td><?php echo htmlspecialchars($row[9]);?></td></tr>
<tr><td>公司地址</td><td><?php echo htmlspecialchars($row[7]);?></td></tr>
<tr><td>公司电话</td><td><?php echo htmlspecialchars($row[8]);?></td></tr>
<tr><td>手机</td><td><?php echo htmlspecialchars($row[10]);?></td></tr>
<tr><td>email</td><td><?php echo htmlspecialchars($row[11]);?></td></tr>
<tr><td>qq</td><td><?php echo htmlspecialchars($row[12]);?></td></tr>
<tr><td>备注</td><td><pre><?php echo $row[14];?></pre></td></tr>
</table>
<center>
<a href="javascript:history.go(-1)">返回</a>
</center>
</body>
</html>
<?php
}else if(isset($action) && ( $action=="add" || $action=="edit" ) ){
if( $action == "edit" ){
if( $_GET["id"] ){
$edit_id = $_GET["id"];
}else if ($_POST["id"]){
$edit_id = $_POST["id"];
}
else
html_error_quit("参数错误");
settype($edit_id, "integer");
if($edit_id < 0)
html_error_quit("参数错误7");
}else {
$sqlstr = "SELECT COUNT(*) FROM addr WHERE userid=\"".$currentuser["userid"]."\"";
$result = mysql_query($sqlstr) or die(mysql_error());
if( ! $result ){
html_error_quit("数据错误");
}else{
$row = mysql_fetch_row($result);
if( ! $row )
html_error_quit("数据错误1");
$allcount = $row[0];
settype($allcount, "integer");
if( $allcount > 400 )
html_error_quit("通讯录满");
}
}
if( $_GET["submit"] || $_POST["submit"] ){
if( $_POST["t_name"] ){
$t_name = $_POST["t_name"];
}else{
html_error_quit("用户名输入错误");
}
$t_name = substr($t_name,0,12);
//$t_name[12]=0;
if( $_POST["t_group"] ){
$t_group = $_POST["t_group"];
$t_group = substr($t_group,0,12);
//$t_group[12]=0;
}else{
$t_group="";
}
if( $_POST["t_bbsid"] ){
$t_bbsid = $_POST["t_bbsid"];
$t_bbsid = substr($t_bbsid,0,12);
//$t_bbsid[12]=0;
}else{
$t_bbsid="";
}
if( $_POST["t_school"] ){
$t_school = $_POST["t_school"];
$t_school = substr($t_school,0,99);
//$t_school[99]=0;
}else{
$t_school="";
}
if( $_POST["t_zipcode"] ){
$t_zipcode = $_POST["t_zipcode"];
$t_zipcode = substr($t_zipcode,0,6);
//$t_zipcode[6]=0;
}else{
$t_zipcode="";
}
if( $_POST["t_homeaddr"] ){
$t_homeaddr = $_POST["t_homeaddr"];
$t_homeaddr = substr($t_homeaddr,0,99);
//$t_homeaddr[99]=0;
}else{
$t_homeaddr="";
}
if( $_POST["t_companyaddr"] ){
$t_companyaddr = $_POST["t_companyaddr"];
$t_companyaddr = substr($t_companyaddr,0,99);
//$t_companyaddr[99]=0;
}else{
$t_companyaddr="";
}
if( $_POST["t_tel_h"] ){
$t_tel_h = $_POST["t_tel_h"];
//$t_tel_h[19]=0;
$t_tel_h = substr($t_tel_h,0,19);
}else{
$t_tel_h="";
}
if( $_POST["t_tel_o"] ){
$t_tel_o = $_POST["t_tel_o"];
$t_tel_o = substr($t_tel_o,0,19);
//$t_tel_o[19]=0;
}else{
$t_tel_o="";
}
if( $_POST["t_mobile"] ){
$t_mobile = $_POST["t_mobile"];
$t_mobile = substr($t_mobile,0,12);
//$t_mobile[12]=0;
}else{
$t_mobile="";
}
if( $_POST["t_email"] ){
$t_email = $_POST["t_email"];
$t_email = substr($t_email,0,29);
//$t_email[29]=0;
}else{
$t_email="";
}
if( $_POST["t_qq"] ){
$t_qq = $_POST["t_qq"];
$t_qq = substr($t_qq,0,9);
//$t_qq[9]=0;
}else{
$t_qq="";
}
if( $_POST["t_birth_year"] ){
$t_birth_year = $_POST["t_birth_year"];
settype($t_birth_year, "integer");
if( $t_birth_year < 1000 || $t_birth_year > 9000 )
$t_birth_year=1900;
}else{
$t_birth_year = 1900;
}
if( $_POST["t_birth_month"] ){
$t_birth_month = $_POST["t_birth_month"];
settype($t_birth_month, "integer");
if( $t_birth_month < 1 || $t_birth_month > 12 )
$t_birth_month=1;
}else{
$t_birth_month = 1;
}
if( $_POST["t_birth_day"] ){
$t_birth_day = $_POST["t_birth_day"];
settype($t_birth_day, "integer");
if( $t_birth_day < 1 || $t_birth_day > 12 )
$t_birth_day=1;
}else{
$t_birth_day = 1;
}
if( $_POST["t_memo"] ){
$t_memo = $_POST["t_memo"];
$t_memo = substr( $t_memo, 0, 99);
//$t_memo{99}=0;
}else{
$t_memo="";
}
if( $action == "add" ){
$sqlstr = "INSERT INTO addr VALUES (NULL, '".$currentuser["userid"]."', '".addslashes($t_name)."','".addslashes($t_bbsid)."','".addslashes($t_school)."','".addslashes($t_zipcode)."','".addslashes($t_homeaddr)."','".addslashes($t_companyaddr)."','".addslashes($t_tel_o)."','".addslashes($t_tel_h)."','".addslashes($t_mobile)."','".addslashes($t_email)."','".addslashes($t_qq)."',\"".$t_birth_year."-".$t_birth_month."-".$t_birth_day."\",'".addslashes($t_memo)."','".addslashes($t_group)."' );";
}else{
$sqlstr = "UPDATE addr SET name='".addslashes($t_name)."',bbsid='".addslashes($t_bbsid)."',school='".addslashes($t_school)."',zipcode='".addslashes($t_zipcode)."',homeaddr='".addslashes($t_homeaddr)."',companyaddr='".addslashes($t_companyaddr)."',tel_o='".addslashes($t_tel_o)."',tel_h='".addslashes($t_tel_h)."',mobile='".addslashes($t_mobile)."',email='".addslashes($t_email)."',qq='".addslashes($t_qq)."',birthday=\"".$t_birth_year."-".$t_birth_month."-".$t_birth_day."\",memo='".addslashes($t_memo)."',groupname='".addslashes($t_group)."' WHERE id=$edit_id AND userid='".$currentuser["userid"]."' ;";
}
//echo $sqlstr;
$result = mysql_query($sqlstr) or die(mysql_error());
if( !$result ){
html_error_quit("失败");
}else{
?>
<a href="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>"><?php if($action == "add") echo "添加"; else echo "修改"; ?>成功,返回</a>
<?php
page_footer(FALSE);
}
}else if($action == "add"){
?>
<center><p><?php echo BBS_FULL_NAME; ?> -- 通讯录条目增加 [用户: <?php echo $currentuser["userid"]; ?>]</p>
</center>
<hr class=default>
<form action="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>&action=add" method=post>
<?php
al_print_form($al);
page_footer(FALSE);
}else{
$sqlstr = "SELECT * FROM addr WHERE userid=\"".$currentuser["userid"]."\" AND id=".$edit_id;
$result = mysql_query($sqlstr) or die(mysql_error());
if( ! $result ){
html_error_quit("数据错误");
}else{
$row = mysql_fetch_row($result);
if( ! $row )
html_error_quit("数据错误1");
?>
<center><p><?php echo BBS_FULL_NAME; ?> -- 通讯录条目修改 [用户: <?php echo $currentuser["userid"]; ?>]</p>
</center>
<hr class=default>
<form action="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>&action=edit&id=<?php echo $edit_id;?>" method=post>
<?php
al_print_form($row);
page_footer(FALSE);
}
}
}
$sqlstr = "SELECT * FROM addr WHERE userid=\"".$currentuser["userid"]."\" ORDER BY ".$order." ".$descstr." LIMIT ".$startnum.",".$count;
$result = mysql_query($sqlstr) or die(mysql_error());
if( ! $result ){
html_error_quit("没有数据");
}else{
page_header("通讯录管理");
?>
<a href="javascript:location.reload()">刷新</a>
</center>
<hr class=default>
<table border="1" width="613" align="center" cellpadding="0" cellspacing="0">
<tr><td>序号</td><td>姓名</td><td>bbsid</td><td>分组</td><td>注释</td><td></td></tr>
<?php
$i=0;
while($row = mysql_fetch_row($result)){
?>
<tr>
<td><?php echo $startnum+$i+1;?></td>
<td><a href="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&action=detail&id=<?php echo $row[0];?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>"><?php echo htmlspecialchars($row[2]);?></a></td>
<td><?php echo htmlspecialchars($row[3]);?></td>
<td><?php echo htmlspecialchars($row[15]);?></td>
<td><pre><?php echo $row[14];?></pre></td>
<td>
<a onclick="return confirm('你真的要删除这条记录吗?')" href="bbsal.php?start=<?php if($i==0 && $startnum > 0) echo ($startnum-1); else echo $startnum;?>&count=<?php echo $count;?>&action=del&id=<?php echo $row[0];?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>">删除</a>
<a href="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&action=edit&id=<?php echo $row[0];?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>">编辑</a>
</td>
</tr>
<?php
$i++;
}
mysql_free_result($result);
}
?>
</table>
<center>
<hr class=default>
<a href="javascript:location.reload()">刷新</a>
<?php
if( $startnum > 0 ){
?>
<a href="bbsal.php?start=<?php if($startnum - $count > 0) echo ($startnum-$count); else echo "0";?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>">上一页</a>
<?php }else{
?>
上一页
<?php
}
if( $i >= $count ){
?>
<a href="bbsal.php?start=<?php echo ($startnum+$count-1);?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>">下一页</a>
<?php }else{
?>
下一页
<?php
}
?>
<a href="bbsal.php?start=<?php echo $startnum;?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=<?php echo $desc;?>&action=add">增加条目</a>
<input type="button" name="csv" value="从csv文件导入" onclick="return GoAttachWindow()" />
<script type="text/javascript">
<!--
function GoAttachWindow(){
var hWnd = window.open("bbsloadcsv.php","_blank","width=300,height=100,scrollbars=yes");
hWnd.focus();
return false;
}
-->
</script>
<script type="text/javascript">
<!--//
function doOrder(){
var oSelectType=document.getElementById("oOrder");
var type=oSelectType.value;
if(type=="name")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=<?php echo $count;?>&order=name&desc=<?php echo $desc;?>";
else if(type=="bbsid")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=<?php echo $count;?>&order=bbsid&desc=<?php echo $desc;?>";
else
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=<?php echo $count;?>&order=groupname&desc=<?php echo $desc;?>";
return;
}
//-->
</script>
按<select name="type" class="input" style="WIDTH: 55px" id="oOrder" onChange="doOrder();">
<option value="name"<?php if( $order=="name" ) { ?> selected="selected"<?php } ?>>姓名</option>
<option value="bbsid"<?php if( $order=="bbsid" ) { ?> selected="selected"<?php } ?>>bbsid</option>
<option value="groupname"<?php if( $order=="groupname" ) { ?> selected="selected"<?php } ?>>分组</option>
</select>
<script type="text/javascript">
<!--//
function doRefresh(){
var oSelectType=document.getElementById("oType");
var type=oSelectType.value;
if(type=="1")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=0";
else
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=<?php echo $count;?>&order=<?php echo $order;?>&desc=1";
return;
}
//-->
</script>
<select name="type" class="input" style="WIDTH: 48px" id="oType" onChange="doRefresh();">
<option value="1"<?php if( $desc==0 ) { ?> selected="selected"<?php } ?>>增序</option>
<option value="2"<?php if( $desc==1 ) { ?> selected="selected"<?php } ?>>倒序</option>
</select>排列
<script type="text/javascript">
<!--//
function doCount(){
var oSelectType=document.getElementById("oCount");
var type=oSelectType.value;
if(type=="10")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=10&order=<?php echo $order;?>&desc=<?php echo $desc;?>";
else if(type == "50")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=50&order=<?php echo $order;?>&desc=<?php echo $desc;?>";
else if(type == "30")
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=30&order=<?php echo $order;?>&desc=<?php echo $desc;?>";
else
window.location="bbsal.php?start=<?php echo ($startnum);?>&count=20&order=<?php echo $order;?>&desc=<?php echo $desc;?>";
return;
}
//-->
</script>
每页显示<select name="type" class="input" style="WIDTH: 40px" id="oCount" onChange="doCount();">
<option value="10"<?php if( $count==10 ) { ?> selected="selected"<?php } ?>>10</option>
<option value="20"<?php if( $count==20 ) { ?> selected="selected"<?php } ?>>20</option>
<option value="30"<?php if( $count==30 ) { ?> selected="selected"<?php } ?>>30</option>
<option value="50"<?php if( $count==50 ) { ?> selected="selected"<?php } ?>>50</option>
</select>个
</center>
</body>
</html>