-
Notifications
You must be signed in to change notification settings - Fork 0
/
namelist.php
90 lines (83 loc) · 2.48 KB
/
namelist.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
<?php
function handler_namelist($tid, $nid)
{
global $user;
$user->set_stat(STAT_DIGESTRACE);
header('Content-Type:text/html; charset=UTF-8');
$types = ext_annpath('namelist');
if(!isset($types[$tid]))
{
ajax_error('Wrong Type.');
}
$cur_type = $types[$tid];
$otypes = array();
foreach($types as $i=>$t)
{
if($t['title'][0] == ' ')
{
continue;
}
array_push($otypes, array('number' => $i,
'text' => @iconv('gbk', 'utf-8',
$t['title'])));
}
$nodes = ext_annpath('namelist/' . $cur_type['filename']);
$onodes = array();
foreach($nodes as $i=>$n)
{
if($n['title'][0] == '-')
{
array_push($onodes, array('number' => $i,
'fake' => true,
'text' => @iconv('gbk', 'utf-8',
substr($n['title'], 1))));
}
else
{
if($nid==0)
{
$nid = $i;
}
array_push($onodes, array('number' => $i,
'text' => @iconv('gbk', 'utf-8',
$n['title'])));
}
}
if(!isset($nodes[$nid]))
{
ajax_error('Wrong Node.');
}
$cur_node = $nodes[$nid];
if($cur_node['title'][0] == '-')
{
ajax_error('Wrong Node index.');
}
$file = @iconv('gbk', 'utf-8',
ext_annfile('namelist/' . $cur_type['filename'] . '/' .
$cur_node['filename'], 0));
$lines = explode("\n", $file);
$namelist = array();
foreach($lines as &$r)
{
$pos = strpos($r, ' ');
if($pos)
{
$r = array('userid' => substr($r, 0, $pos),
'intro' => substr($r, $pos));
}
else
{
$r = trim($r, '\0\t\x0B\r\n ');
}
}
global $tpl;
$tpl->loadTemplate('standard/namelist.html');
echo $tpl->render(array('types' => $otypes,
'nodes' => $onodes,
'tid' => $tid,
'nid' => $nid,
'title' => @iconv('gbk', 'utf-8',
$cur_node['title']),
'list' => $lines));
}
?>