1 | <? |
---|
2 | require_once( "db.php" ); |
---|
3 | |
---|
4 | class Killboard { |
---|
5 | |
---|
6 | function Killboard( $site ) |
---|
7 | { |
---|
8 | $this->qry_ = new DBQuery(); |
---|
9 | |
---|
10 | $this->site_ = $site; |
---|
11 | $this->config_ = new Config( $site ); |
---|
12 | } |
---|
13 | |
---|
14 | function isSuspended() |
---|
15 | { |
---|
16 | $this->execQuery(); |
---|
17 | return $this->row_['rtl_suspended'] == "1"; |
---|
18 | } |
---|
19 | |
---|
20 | function getConfig() |
---|
21 | { |
---|
22 | $this->execQuery(); |
---|
23 | return $this->config_; |
---|
24 | } |
---|
25 | |
---|
26 | function hasCampaigns( $active = false ) |
---|
27 | { |
---|
28 | $qry = new DBQuery(); |
---|
29 | $sql = "select ctr_id |
---|
30 | from kb3_contracts |
---|
31 | where ctr_campaign = 1 |
---|
32 | and ctr_site = '".$this->site_."'"; |
---|
33 | if ( $active ) $sql .= " and ctr_ended is null"; |
---|
34 | $qry->execute( $sql ) or die ( $qry->getErrorMessage() ); |
---|
35 | return ( $qry->recordCount() > 0 ); |
---|
36 | } |
---|
37 | |
---|
38 | function hasContracts( $active = false ) |
---|
39 | { |
---|
40 | $qry = new DBQuery(); |
---|
41 | $sql = "select ctr_id |
---|
42 | from kb3_contracts |
---|
43 | where ctr_campaign = 0 |
---|
44 | and ctr_site = '".$this->site_."'"; |
---|
45 | if ( $active ) $sql .= " and ( ctr_ended is null or now() <= ctr_ended )"; |
---|
46 | $qry->execute( $sql ) or die ( $qry->getErrorMessage() ); |
---|
47 | return ( $qry->recordCount() > 0 ); |
---|
48 | } |
---|
49 | |
---|
50 | function execQuery() |
---|
51 | { |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | class Config |
---|
56 | { |
---|
57 | function Config( $site ) |
---|
58 | { |
---|
59 | $this->qry_ = new DBQuery(); |
---|
60 | $this->sql_ = "select * |
---|
61 | from kb3_config |
---|
62 | where cfg_site = '".$site."'"; |
---|
63 | |
---|
64 | $this->site_ = $site; |
---|
65 | } |
---|
66 | |
---|
67 | function getStyleName() |
---|
68 | { |
---|
69 | $this->execQuery(); |
---|
70 | return $this->style_name_; |
---|
71 | } |
---|
72 | |
---|
73 | function getStyleBanner() |
---|
74 | { |
---|
75 | $this->execQuery(); |
---|
76 | return $this->style_banner_; |
---|
77 | } |
---|
78 | |
---|
79 | function getPostPassword() |
---|
80 | { |
---|
81 | $this->execQuery(); |
---|
82 | return $this->post_password_; |
---|
83 | } |
---|
84 | |
---|
85 | function getPostMailto() |
---|
86 | { |
---|
87 | $this->execQuery(); |
---|
88 | return $this->post_mailto_; |
---|
89 | } |
---|
90 | |
---|
91 | function getKillPoints() |
---|
92 | { |
---|
93 | $this->execQuery(); |
---|
94 | return $this->kill_points_; |
---|
95 | } |
---|
96 | |
---|
97 | function getLeastActive() |
---|
98 | { |
---|
99 | $this->execQuery(); |
---|
100 | return $this->least_active_; |
---|
101 | } |
---|
102 | |
---|
103 | function setConfig( $key, $value ) |
---|
104 | { |
---|
105 | $qry = new DBQuery(); |
---|
106 | $qry->execute( "select cfg_value from kb3_config |
---|
107 | where cfg_key = '".$key."' |
---|
108 | and cfg_site = '".$this->site_."'" ); |
---|
109 | if ( $qry->recordCount() ) { |
---|
110 | $sql = "update kb3_config |
---|
111 | set cfg_value = '".$value."' |
---|
112 | where cfg_site = '".$this->site_."' |
---|
113 | and cfg_key = '".$key."'"; |
---|
114 | } else { |
---|
115 | $sql = "insert into kb3_config values ( '".$this->site_."', |
---|
116 | '".$key."', |
---|
117 | '".$value."' )"; |
---|
118 | } |
---|
119 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
120 | } |
---|
121 | |
---|
122 | function setStyleName( $name ) |
---|
123 | { |
---|
124 | $this->setConfig( "style_name", $name ); |
---|
125 | } |
---|
126 | |
---|
127 | function setStyleBanner( $banner ) |
---|
128 | { |
---|
129 | $this->setConfig( "style_banner", $banner ); |
---|
130 | } |
---|
131 | |
---|
132 | function setPostPassword( $password ) |
---|
133 | { |
---|
134 | $this->setConfig( "post_password", $password ); |
---|
135 | } |
---|
136 | |
---|
137 | function setPostMailto( $mailto ) |
---|
138 | { |
---|
139 | $this->setConfig( "post_mailto", $mailto ); |
---|
140 | } |
---|
141 | |
---|
142 | function setKillPoints( $flag ) |
---|
143 | { |
---|
144 | $this->setConfig( "kill_points", $flag ); |
---|
145 | } |
---|
146 | |
---|
147 | function setLeastActive( $flag ) |
---|
148 | { |
---|
149 | $this->setConfig( "least_active", $flag ); |
---|
150 | } |
---|
151 | |
---|
152 | function execQuery() |
---|
153 | { |
---|
154 | if ( !$this->qry_->executed_ ) { |
---|
155 | $this->qry_->execute( $this->sql_ ); |
---|
156 | |
---|
157 | while ( $row = $this->qry_->getRow() ) |
---|
158 | { |
---|
159 | switch( $row['cfg_key'] ) { |
---|
160 | case 'style_name': |
---|
161 | $this->style_name_ = $row['cfg_value']; |
---|
162 | break; |
---|
163 | case 'style_banner': |
---|
164 | $this->style_banner_ = $row['cfg_value']; |
---|
165 | break; |
---|
166 | case 'post_password': |
---|
167 | $this->post_password_ = $row['cfg_value']; |
---|
168 | break; |
---|
169 | case 'post_mailto': |
---|
170 | $this->post_mailto_ = $row['cfg_value']; |
---|
171 | break; |
---|
172 | case 'kill_points': |
---|
173 | $this->kill_points_ = $row['cfg_value']; |
---|
174 | break; |
---|
175 | case 'least_active': |
---|
176 | $this->least_active_ = $row['cfg_value']; |
---|
177 | break; |
---|
178 | } |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | ?> |
---|