-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBstatistics.php
More file actions
136 lines (129 loc) · 3.75 KB
/
DBstatistics.php
File metadata and controls
136 lines (129 loc) · 3.75 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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of DBstatistics
*
* @author Yasha
*/
include '../db/dbConnector.php';
class DBstatistics {
private $username;
private $userquery;
private $articlequery;
private $id;
private $db;
private $articledata;
private $data;
function __construct($username,$id, $command)
{
$db=new DbConnector();
$this->username=$username;
$this->id=$id;
$this->db=$db;
$this->articledata=$db->fetchmyArray("select confirmed from articles where id= ".$id);
switch ($command)
{
case "feature": $this->data=2; break;
case "approve": $this->data=1; break;
case "unfeature": $this->data=1; break;
case "unapprove": $this->data=0; break;
case "reject": $this->data=-1; break;
}
$this->db->query("update articles set confirmed=$this->data where id= ".$this->id);
}
//
//
//public function Featured()
//{
// $setart="";
// $setuser="";
// if($this->articledata[0][0]!=2)
// {
// echo "path pass feature<br>";
//
// $setart='featured=1';
// $setuser='featuredpost=featuredpost+1, score=score+5';
// if($this->articledata[0][0]!=1)
// {
// $setart.=', confirmed=1';
// $setuser.=', articlespost=articlespost+1, score=score+0.5';
// } $this->articlequery='update articles set '.$setart.' where id='.$this->id;
// $this->userquery='update users set '.$setuser.' where username="'.$this->username.'" ';
// }
//
//
//
//
//
//
//
//}
//
//public function Approved()
//{
// echo "Approved!";
// if($this->articledata[0][0]!=1)
// {
// echo "path pass approve<br>";
//
// $this->userquery='update users set articlespost=articlespost+1, score=score+0.5 where username="'.$this->username.'" ';
// $this->articlequery='update articles set confirmed=1, featured=0 where id='.$this->id;
//
// echo "path passed!";
//
// }
//}
//public function unApproved()
//{
// $setart="";
// $setuser="";
// if($this->articledata[0][1]!=0)
// {
// $setart='featured=0';
// $setuser='featuredpost=featuredpost-1, score=score-5';
// if($this->articledata[0][0]!=0)
// {
// $setart.=', confirmed=0';
// $setuser.=', articlespost=articlespost-1, score=score-0.5';
// } $this->articlequery='update articles set '.$setart.' where id='.$this->id;
// $this->userquery='update users set '.$setuser.' where username="'.$this->username.'" ';
// }
//
//
//}
//public function unFeatured()
//{
//
// if($this->articledata[0][1]!=0)
// {
// echo "path pass unfeature<br>";
// $this->userquery='update users set featuredpost=featuredpost-1, score=score-5 where username="'.$this->username.'" ';
// $this->articlequery='update articles set featured=0 where id='.$this->id;
// }
//}
//
//public function Rejected()
//{
//
//// $setart="confirmed=2, featured=2";
////$setuser="";
////if($this->articledata[0][0]==1)
////{
//// $setuser.='articlespost=articlespost-1, score=score-0.5';
////
//// if($this->articledata[0][1]==1)
//// {
//// $setuser.=',featuredpost=featuredpost-1, score=score-5';
////}
//// $this->userquery='update users set '.$setuser.' where username="'.$this->username.'" ';
//// echo $this->userquery;
//// }
// $this->articlequery='update articles set confirmed=-1 where id='.$this->id;
// echo "<br>".$this->articlequery."<br>";
//
// }
}
?>