westdc-zf1/application/admin/controllers/StatController.php

137 lines
4.7 KiB
PHP

<?php
class Admin_StatController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
}
function postDispatch()
{
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
$sql="select (select count(id) from users) as alluser,
(select count(id) from normalmetadata) as alldata,
(select count(id) as num from dataorder where status=0) as onlinedown,
(select count(id) as num from dataorder where offlineappid>0 and status>4) as offlinepass,
(select count(id) as num from dataorder where offlineappid>0 and status in (2,3,4)) as offlineunfinished,
(select count(id) as num from dataorder where offlineappid>0 and status=-1) as offlinedenied";
$this->view->stat=$this->db->fetchRow($sql);
//下载量统计
$sql = "select sum(num) as num from (select m.filesize/1024 as num,m.title,d.userid from dataorder d left join metadata m on d.uuid=m.uuid where (d.status=0 or d.status=5) and m.filesize>0 group by m.title,d.userid,m.filesize) as t";
$res = $this->db->query($sql);
$allsize = $res->fetch();
$this->view->allsize = $allsize;
$sql = "select sum(num) as num from (select m.filesize/1024 as num,m.title,d.userid from dataorder d left join metadata m on d.uuid=m.uuid where d.status=5 and m.filesize>0 group by m.title,d.userid,m.filesize) as t";
$res = $this->db->query($sql);
$offlinesize = $res->fetch();
$this->view->offlinesize = $offlinesize;
$sql = "select sum(num) as num from (select m.filesize/1024 as num,m.title,d.userid from dataorder d left join metadata m on d.uuid=m.uuid where d.status=0 and m.filesize>0 group by m.title,d.userid,m.filesize) as t";
$res = $this->db->query($sql);
$onlinesize = $res->fetch();
$this->view->onlinesize = $onlinesize;
}//indexAction 首页
function unitAction()
{
//各单位下载情况
$sql = "select count(d.id) as num,o.unit from dataorder d
left join offlineapp o on o.id=d.offlineappid
where d.offlineappid>0 and o.unit is not null and d.status>4
group by o.unit";
$fe = $this->db->query($sql);
$unitoffline = $fe->fetchAll();
$this->view->unitoffline = $unitoffline;
//各单位在线下载情况
$sql = "select count(d.id) as num,o.unit from dataorder d
left join onlineapp o on o.id=d.onlineappid
where d.onlineappid>0 and o.unit is not null
group by o.unit";
$fe = $this->db->query($sql);
$unitonline = $fe->fetchAll();
$this->view->unitonline = $unitonline;
}//分单位统计
function monthAction(){
$y = $this->_request->getParam('y');
if(!empty($y)||!is_numeric($y))
{
$n = date("Y",time());
if($y<2011 || $y>$n)
{
$y=$n;
}
}
$this->view->y = $y;
$sql = "select count(extract(month from ts_created)) as c,extract(month from ts_created) as m,extract(year from ts_created) as y from onlineapp
where extract(year from ts_created)='$y'
group by extract(month from ts_created),extract(year from ts_created)
order by extract(year from ts_created),extract(month from ts_created)";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
$this->view->data = $rows;
$sql = "select count(extract(month from ts_created)) as c,extract(month from ts_created) as m,extract(year from ts_created) as y from offlineapp
where extract(year from ts_created)='$y'
group by extract(month from ts_created),extract(year from ts_created)
order by extract(year from ts_created),extract(month from ts_created)";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
if(count($rows)<=0)
{
$this->view->offline="";
}
$this->view->offline = $rows;
$sql = "select count(extract(month from ts_created)) as c,extract(month from ts_created) as m,extract(year from ts_created) as y from users
where extract(year from ts_created)='$y'
group by extract(month from ts_created),extract(year from ts_created)
order by extract(year from ts_created),extract(month from ts_created)";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
if(count($rows)<=0)
{
$this->view->newuser="";
}
$this->view->newuser = $rows;
}//按月份统计
function awstatswebAction()
{
}//awstats web 统计
function awstatsftpAction()
{
}//awstats ftp 统计
function webalizerAction()
{
}//webalizer 统计
}