-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.class.php
More file actions
81 lines (73 loc) · 2.37 KB
/
main.class.php
File metadata and controls
81 lines (73 loc) · 2.37 KB
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
<?php
class main{
function __construct()
{
$this->session=new session();
$this->smarty=new Smarty();
$this->smarty->setCompileDir("compile");
$this->smarty->setTemplateDir("template");
}
/*
* 跳转
* */
public function jump($url,$message){
$this->smarty->assign("url",$url);
$this->smarty->assign("message",$message);
$this->smarty->display("index/tishi.html");
}
/*
* 检测登陆
* */
function checkLogin(){
if(!($this->session->get("is_login")&&!empty(MVC))){
$url="index.php?m=admin&f=index&a=login";
$message="请登陆";
$this->jump($url,$message);
return false;
}else{
return true;
}
}
function ziduanjiangxu($oldarr,$shuxing){
$arr=Array();
for($i=0;$i<count($oldarr);$i++){
$arr[$i]=$oldarr[$i][$shuxing];
}
rsort($arr);
$newarr=Array();
for($m=0;$m<count($arr);$m++){
for($n=0;$n<count($oldarr);$n++){
if($arr[$m]==$oldarr[$n][$shuxing]){
$newarr[$m]=$oldarr[$n];
}
}
}
return $newarr;
}
//数据读取
function publicdata(){
//获取目录
$db=new db("category");
$result=$db->select();
$this->smarty->assign('result',$result);
//获取文章目录
$dbshows=new db("shows");
$resultshows=$dbshows->select();
$resultshows=array_reverse($resultshows);
$this->smarty->assign('resultshows',$resultshows);
//收藏排行
$resultshoucang=$this->ziduanjiangxu($resultshows,"shoucangshu");
$this->smarty->assign('resultshoucang',$resultshoucang);
//评论排行
$resultpinglun=$this->ziduanjiangxu($resultshows,"pinglunshu");
$this->smarty->assign('resultpinglun',$resultpinglun);
//推荐排行
$resulttuijian=Array();
for($i=0;$i<count($resultshows);$i++){
if($resultshows[$i]["tuijian"]==1){
$resulttuijian[$i]=$resultshows[$i];
}
}
$this->smarty->assign('resulttuijian',$resulttuijian);
}
}