forked from BNUACM/bnuoj-web-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_sidebar.php
61 lines (58 loc) · 1.88 KB
/
common_sidebar.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
<?php
include_once("conn.php");
?>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
<h1>Upcoming Next</h1>
<p>
<?php
$sql="select cid,title,start_time,type from contest where start_time>now() and isvirtual=0 order by start_time limit 0,5";
$res=mysql_query($sql);
$none=true;
while (list($tcid,$tctitle,$tcsttime,$tctype)=mysql_fetch_array($res)) {
if ($tctype==1) $tctitle.=" [CF]";
$none=false;
?>
<a href='contest_show.php?cid=<?php echo $tcid; ?>'><?php echo $tctitle; ?></a> at <?php echo $tcsttime; ?><br />
<?php
}
if ($none) {
?>
No upcoming contest.
<?php
}
?>
</p>
</div>
<div class="sidebar_base"></div>
</div>
<div class="sidebar">
<div class="sidebar_top"></div>
<div class="sidebar_item">
<h1>Latest News <span style="font-size:12px"><a href="news.php">[more...]</a></span></h1>
<?php
$sql="select * from news order by time_added desc limit 0,$newsperpage";
$res=mysql_query($sql);
$none=true;
while ($row=mysql_fetch_array($res)) {
$none=false;
$row['title']=strip_tags($row['title']);
if (strlen($row['title'])>30) $row['title']=mb_strcut($row['title'],0,30,'UTF-8')."<a name='".$row['newsid']."' class='newslink' href='#'>[...]</a>";
$row['content']=strip_tags($row['content']);
if (strlen($row['content'])>100) $row['content']=mb_strcut($row['content'],0,100,'UTF-8');
$row['content'].="<a name='".$row['newsid']."' class='newslink' href='#'>[...]</a>";
?>
<h4><?php echo $row['title']; ?></h4>
<p><?php echo $row['content']; ?></p>
<?php
}
if ($none) {
?>
No News.
<?php
}
?>
</div>
<div class="sidebar_base"></div>
</div>