/var/www/(Del)tsolpv.com/2013/sc/servicedownload.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
<?php require_once('../webadmin/configure.php');
$result0 mysql_query("SELECT * FROM home ");
$row0 mysql_fetch_array($result0,MYSQL_ASSOC);
$result mysql_query("SELECT * FROM sys_menu WHERE mpage = 'service' ");
$row mysql_fetch_array($result,MYSQL_ASSOC);

$result1 mysql_query("SELECT * FROM service WHERE serid = ".safe_param($_GET['serid'])." AND serpagemodule = 'servicedownload' AND serstatus = '1' ORDER BY sersort ASC ");
if (
mysql_num_rows($result1) > 0){
    
$row1 mysql_fetch_array($result1,MYSQL_ASSOC);
} else {
    
header("Location: index.php");
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title><?=$row1{'metatitlesc'};?></title>
<meta name="keywords" content="<?=$row1{'metakeywordsc'};?>" />
<meta name="description" content="<?=$row1{'metadescsc'};?>" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.banner').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
</script>

</head>
<body>
<div id="container">
   <!-- Header -->
   <?php require_once('header.php');?>
   <!-- Main Content -->
   <div id="body">
       <div id="body_content">
        <div id="submenu">
            <ul><?php // Left Menu
            
$result3 mysql_query("SELECT * FROM service WHERE serstatus = '1' ORDER BY sersort ASC ");
            while (
$row3 mysql_fetch_array($result3,MYSQL_ASSOC)){
                echo 
"<li><a href='".$row3{'serpagemodule'}.".php?serid=".$row3{'serid'}."'>".$row3{'sertitlesc'}."</a></li>";
            }
?></ul>
        </div>

        <div id="maincontent">
            <?php if(!empty($row1{'serbannersc'})) { 
                echo 
'<div id="pagebanner"><a href="'.$row1{'serbannerlinksc'}.'"><img src="../pagebanner/'.$row1{'serbannersc'}.'" width="670" /></a></div>'; }?>
            <div id="pagetitle" class="pagetitle"><?=$row1{'sertitlesc'};?></div>
            <div id="path" class="path"><a href="index.php">主页</a> > <?=$row{'mtitlesc'};?> > <?=$row1{'sertitlesc'};?></div>
            <div id="pagecontent" class="pagecontent"><?=$row1{'serdescsc'};?><br /><br />
            <?php 
            
//$tbl_name="property";        //your table name
            // How many adjacent pages should be shown on each side?
            
$adjacents 5;
            
            
/* 
               First get total number of rows in data table. 
               If you have a WHERE clause in your query, make sure you mirror it here.
            */
            //$query = "SELECT COUNT(*) as num FROM $tbl_name";
            
            
$query "SELECT COUNT(*) as num FROM service_download WHERE serid = ".$row1{'serid'}." AND serdlwstatus = '1' ";
            
//echo 'query'.$query.'<br />';
            
$total_pages mysql_fetch_array(mysql_query($query));
            
$total_pages $total_pages[num];
            
            
/* Setup vars for query. */
            
$targetpage "servicedownload.php";     //your file name  (the name of this file)
            
$limit 10;                                 //how many items to show per page
            
$page $_GET['page'];
            if(
$page
                
$start = ($page 1) * $limit;             //first item to display on this page
            
else
                
$start 0;                                //if no page var is given, set start to 0
            
            /* Get data. */
            
$sql5 "SELECT * FROM service_download WHERE serid = ".$row1{'serid'}." AND serdlwstatus = '1' ";
            
$sql5 .= "ORDER BY serdlwsort ASC LIMIT $start$limit ";            
            
//echo $sql5;
            
$result5 mysql_query($sql5);

            
/* Setup page vars for display. */
            
if ($page == 0$page 1;                    //if no page var is given, default to 1.
            
$prev $page 1;                            //previous page is page - 1
            
$next $page 1;                            //next page is page + 1
            
$lastpage ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
            
$lpm1 $lastpage 1;                        //last page minus 1
            
            
$pagination "";
            if(
$lastpage 1)
            {    
                
$pagination .= "<div class=\"pagination\">";
                
//previous button
                
if ($page 1
                    
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$prev\">«</a>";
                else
                    
$pagination.= "<span class=\"disabled\">«</span>";    
                
                
//pages    
                
if ($lastpage + ($adjacents 2))    //not enough pages to bother breaking it up
                
{    
                    for (
$counter 1$counter <= $lastpage$counter++)
                    {
                        if (
$counter == $page)
                            
$pagination.= "<span class=\"current\">$counter</span>";
                        else
                            
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$counter\">$counter</a>";                    
                    }
                }
                elseif(
$lastpage + ($adjacents 2))    //enough pages to hide some
                
{
                    
//close to beginning; only hide later pages
                    
if($page + ($adjacents 2))        
                    {
                        for (
$counter 1$counter + ($adjacents 2); $counter++)
                        {
                            if (
$counter == $page)
                                
$pagination.= "<span class=\"current\">$counter</span>";
                            else
                                
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$counter\">$counter</a>";                    
                        }
                        
$pagination.= "...";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$lpm1\">$lpm1</a>";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$lastpage\">$lastpage</a>";        
                    }
                    
//in middle; hide some front and some back
                    
elseif($lastpage - ($adjacents 2) > $page && $page > ($adjacents 2))
                    {
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=1\">1</a>";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=2\">2</a>";
                        
$pagination.= "...";
                        for (
$counter $page $adjacents$counter <= $page $adjacents$counter++)
                        {
                            if (
$counter == $page)
                                
$pagination.= "<span class=\"current\">$counter</span>";
                            else
                                
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$counter\">$counter</a>";                    
                        }
                        
$pagination.= "...";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$lpm1\">$lpm1</a>";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$lastpage\">$lastpage</a>";        
                    }
                    
//close to end; only hide early pages
                    
else
                    {
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=1\">1</a>";
                        
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=2\">2</a>";
                        
$pagination.= "...";
                        for (
$counter $lastpage - (+ ($adjacents 2)); $counter <= $lastpage$counter++)

                        {
                            if (
$counter == $page)
                                
$pagination.= "<span class=\"current\">$counter</span>";
                            else
                                
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$counter\">$counter</a>";                    
                        }
                    }
                }
                
//next button
                
if ($page $counter 1
                    
$pagination.= "<a href=\"$targetpage?serid=".$row1{'serid'}."&page=$next\">»</a>";
                else
                    
$pagination.= "<span class=\"disabled\">»</span>";
                
$pagination.= "</div>\n";        
            }

            
?>
            <table width="670" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="400" class="download-table-title">Document Name</td>
                <td width="120" class="download-table-title">Document Type</td>
                <td width="120" class="download-table-title">Document Size</td>
              </tr>
              <?php    while ($row5 mysql_fetch_array($result5,MYSQL_ASSOC)){ 
                      
$filename '../service_download/'.$row5{'serdlwfilesc'};
                    
$ext pathinfo($filenamePATHINFO_EXTENSION);                     
              
?>
              <tr>
                <td class="download-table-detail"><a href="../service_download/<?=$row5{'serdlwfilesc'};?>"><?=$row5{'serdlwtitlesc'};?></a></td>
                <td class="download-table-detail"><?=$ext;?></td>
                <td class="download-table-detail"><?=formatbytes("../service_download/".$row5{'serdlwfilesc'}, "MB");?></td>
              </tr>
              <?php ?>
            </table>
            </div>
            <div id="pagination"><?=$pagination;?></div>
        </div>
        <div class="clear"></div>
    </div>
   </div>
   <!-- Footer -->
   <?php require_once('footer.php');?>
</div>
</body>
</html>
<?php
function formatbytes($file$type)  
{  
    switch(
$type){  
        case 
"KB":  
            
$filesize filesize($file) * .0009765625// bytes to KB  
        
break;  
        case 
"MB":  
            
$filesize = (filesize($file) * .0009765625) * .0009765625// bytes to MB  
        
break;  
        case 
"GB":  
            
$filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625// bytes to GB  
        
break;  
    }  
    if(
$filesize <= 0){  
        return 
$filesize 'unknown file size';}  
    else{return 
round($filesize2).' '.$type;}  

?>