discuzX思可觅 扩展功能——死种统计beta1

由于上传员也换了好多年
有些资源真的保种下来
但是一个个翻来找也是不科学的,所以写了一个小玩意
用来统计死种的
但是这个设计上也是有问题的,只能用来统计固定的一段时间内的死种
而且长期运行会导致数据库臃肿
现在打算先上了beta1的版本作为纪念
然后重新开始写一个beta2的
——————————————–
先是种子的统计页面

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
// +----------------------------------------------------------------------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Authors: Original Author ct ctnmb.com                                |
// |          version 20151123                                            |
// +----------------------------------------------------------------------+
//
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>荔香站- 统计死种</title>
</head>
<?php
$con = mysql_connect("10.110.2.17","root","zxxccccc");    //连接数据库
 
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("discuzx", $con);     //数据库
mysql_query('set names gbk');    //数据库编码
$perNumber=200; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
$count=mysql_query("SELECT count(*) FROM (select *,count(*) from pre_ctbit_zztj group by tid having count(*) >= (select times from pre_ctbit_tjtimes where id =9 )) as yy"); //获得记录总数
$rs=mysql_fetch_array($count); 
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数
 
$x1 = "select times from pre_ctbit_tjtimes where id =9  ";   
$x2 = mysql_query($x1, $con); 
$x3 = mysql_fetch_array($x2);
 echo "统计次数:&nbsp;".$x3['times'];
 echo "&nbsp;&nbsp;&nbsp;统计天数:&nbsp;".ceil($x3['times']/3) ."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;初步死种数:".$totalNumber."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每天统计三次,分别是14:10, 19:10和23:40<br>
 ----------------------------------------------------------------------------------------------------------
 <br>";
 
if (!isset($page)) {
 $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的记录
$result=mysql_query("select *,count(*) from pre_ctbit_zztj group by tid having count(*) >= (select times from pre_ctbit_tjtimes where id =9 ) ORDER BY COUNT( * ) DESC limit $startCount,$perNumber"); //根据前面的计算出开始的记录和记录数
while ($row=mysql_fetch_array($result)) {
 echo "<a href='http://res.hltz.net/zyq17/m".$row['tid']."' target='_blank'>".$row['filename']."</a>";
 echo "&nbsp;&nbsp;&nbsp;没种天数:".ceil($row['count(*)']/3) ."<br>
 ----------------------------------------------------------------------------------------------------------
 <br>"; //显示数据库的内容
}
if ($page != 1) { //页数不等于1
?>
<a href="/tj.php?page=<?php echo $page - 1;?>">上一页</a> <!--显示上一页-->
<?php
}
for ($i=1;$i<=$totalPage;$i++) {  //循环显示出页面
?>
<a href="/tj.php?page=<?php echo $i;?>"><?php echo $i ;?></a>
<?php
}
if ($page<$totalPage) { //如果page小于总页数,显示下一页链接
?>
<a href="/tj.php?page=<?php echo $page + 1;?>">下一页</a>
<?php
} 
?>

cron_zztj.php这个交给discuz计划任务运行统计

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// +----------------------------------------------------------------------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Authors: Original Author ct ctnmb.com                                |
// |          version 20151123                                            |
// +----------------------------------------------------------------------+
//
$con = mysql_connect("10.110.2.17","root","zxccccccc");    //连接数据库
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("discuzx", $con);     //数据库
mysql_query('set names gbk');    //数据库编码
$ss1=mysql_query("insert into pre_ctbit_zztj(tid,filename) select tid,filename from pre_xbtit_files where seeds = 0 ");
$ss2 = mysql_query($ss1, $con);  
function update($FieldName2)
{
    mysql_query("update pre_ctbit_tjtimes set $FieldName2 where id = 9 ");      
}
mysql_query("SET NAMES utf8");  
update("times = times+1");

SQL结构

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
-- phpMyAdmin SQL Dump
-- version phpStudy 2014
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2016 �?03 �?15 �?11:19
-- 服务器版本: 5.5.40
-- PHP 版本: 5.5.17
 
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
 
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
 
--
-- 数据库: `xbit`
--
 
-- --------------------------------------------------------
 
--
-- 表的结构 `pre_ctbit_tjtimes`
--
 
CREATE TABLE IF NOT EXISTS `pre_ctbit_tjtimes` (
  `times` INT(10) NOT NULL,
  `days` INT(10) NOT NULL,
  `id` INT(5) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
 
-- --------------------------------------------------------
 
--
-- 表的结构 `pre_ctbit_zztj`
--
 
CREATE TABLE IF NOT EXISTS `pre_ctbit_zztj` (
  `tid` INT(8) NOT NULL,
  `filename` VARCHAR(250) NOT NULL,
  `noseedtimes` INT(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
 
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
死种统计

死种统计

git:http://git.oschina.net/wsct/count-dead-seed

添加评论