-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.class.php
More file actions
executable file
·149 lines (121 loc) · 3.54 KB
/
Copy pathweb.class.php
File metadata and controls
executable file
·149 lines (121 loc) · 3.54 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
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
<?php
include 'mysql_conf.php';
$img_addr = 'http://cdn.zypc.org/usr/local/cdn/img/';
class web{
public $Id = '';
public $Name = '';
public $User = '';
public $College = '';
public $Words = '';
public $Ticket = 0;
public $Url = '';
public $Auth = 0;
public function get_Id(){
return $this->$Id;
}
public function get_Name(){
return $this->$Name;
}
public function get_User(){
return $this->$User;
}
public function get_College(){
return $this->$College;
}
public function get_Words(){
return $this->$Words;
}
public function get_Ticket(){
return $this->$Ticket;
}
public function get_Url(){
return $this->$Url;
}
public function get_Auto(){
return $this->$Auth;
}
public function set_Id($name){
$sql = 'select id from web where name='.$this->$Name;
$query = mysql_query($sql);
$result = mysql_fetch_assoc($query);
$this->$Id = $result['name'];
}
public function set_Name($name){
$Name = $name;
$this->$Name = $Name;
$sql = 'insert into web(name) values(\''.$Name.'\')';
$query = mysql_query($sql);
echo '123';
}
public function set_User($user,$name){
$User = $user;
$this->$User = $User;
$sql = 'insert into web(provider) values(\''.$User.'\') where name='.$name;
$query = mysql_query($sql);
}
public function set_Words($words,$name){
$Words = $words;
$this->$Words = $Words;
$sql = 'update web set intro='.$Words.'where name='.$name;
$query = mysql_query($sql);
}
public function set_College($college,$name){
$College = $college;
$this->$College = $College;
$sql = 'update web set intro='.$College.'where name='.$name;
$query = mysql_query($sql);
}
public function set_Ticket($ticket,$name){
$Ticket = $ticket;
$this->$Ticket = $Ticket;
$sql = 'update web set ticket='.$Ticket.'where name='.$name;
$query = mysql_query($sql);
}
public function set_Url($url,$name){
$Url = $url;
$this->$Url = $Url;
$sql = 'update web set url='.$Url.'where name='.$name;
$query = mysql_query($sql);
}
public function set_Auth($auth,$name){
$Auth = $auth;
$this->$Auth = $Auth;
$sql = 'update web set auth='.$Auth.'where name='.$name;
$query = mysql_query($sql);
}
//获取封面图片
public function get_index_img(){
$index_img = $img_addr.$this->$Name.'/index.jpg';
echo json_encode($index_img);
}
//获取所有资源
public function get_all(){
$dir = $img_addr.$this->$Name."/";
$file=scandir($dir);
for($i=2;$i<=count($file);$i++){
$file[$i] = $dir.$file[$i];
}
echo json_encode($file);//[2]开始是第一个地址
}
//投票
public function vote($web_id,$voter){
$sql = 'select flag from voter where name='.$voter;
$query = mysql_query($sql);
$result = mysql_fetch_assoc($query);
if($result['flag'] == 0 && $result != null){
if($_SESSION['group'] == 'teacher'){
$sql_1 = 'update web set ticket=ticket+1 where id='.$web_id;
$sql_2 = "insert into voter(name,type,flag) values('".$_SESSION['username']."','".$_SESSION['group']."',1)";
$query_1 = mysql_query($sql_1);
$query_2 = mysql_query($sql_2);
}else if($_SESSION['group'] != 'teacher' && $this->$Auth == 0){
$sql_1 = 'update web set ticket=ticket+1 where id='.$web_id;
$sql_2 = "insert into voter(name,type,flag) values('".$_SESSION['username']."','".$_SESSION['group']."',1)";
$query_1 = mysql_query($sql_1);
$query_2 = mysql_query($sql_2);
}
}else{
echo "<script>alert('已经投过票!')</script>";
}
}
}