-
Notifications
You must be signed in to change notification settings - Fork 0
/
ads_approval.php
271 lines (184 loc) · 7.82 KB
/
ads_approval.php
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
include ("include/config.php");
if(!isset($_SESSION[uid]))
header("location: account.php");
$advid = mysql_fetch_assoc(mysql_query("select * from advertisersinfo where adv_id = '$_GET[adv_id]'"));
$post = mysql_fetch_assoc(mysql_query("select * from users where uid = '$advid[uid]' "));
$pubname = mysql_result(mysql_query("select websitename from publishersinfo where pid = '$advid[pid]'"),0,0);
if($advid[length] == 0) {
$adlen = 'N/A (PPC)';
$adcost = $advid[ppc_balance];
}
else {
$adlen = $advid[length].' Day';
$adcost = $advid[price];
}
if(isset($_POST[reject])) {
if(mysql_query("update advertisersinfo set approved='R' where adv_id='$_GET[adv_id]' and pub_uid='$_SESSION[uid]' and approved='N' and is_paid='Y' and is_auth='Y' ")) {
$price = mysql_fetch_assoc(mysql_query("select uid, price, ppc_balance from advertisersinfo where pub_uid='$_SESSION[uid]' and adv_id = '$_GET[adv_id]' and is_paid = 'Y' and is_auth='Y' and approved='R'"));
$adv_uid = $price[uid];
if($price[ppc_balance] == 0)
$cost = $price[price];
else $cost = $price[ppc_balance];
mysql_query("update users set balance = ( balance + $cost ) where uid='$adv_uid' ");
}
$to = $post[email];
// subject
$subject = 'Ad Rejected';
// message
$message = "
<html>
<head>
<title>Ad Rejected</title>
</head>
<body>
Your ad for the following website has been rejected,<br />
<br />
Website: $pubname<br />
Ad Length: $adlen<br />
Ad Cost: $_config[currency] $cost<br />
The website owner may have left a reason why they have rejected your ad. <br />
You can read this reason by logging into your account and clicking on the 'Current Ads Running' and viewing your rejected ads there. <br />
<br />
<br />
<br />
Your account has now been credited with the amount, $_config[currency] $cost <br />
<br />
You can now purchase any other ads upto the value you have just been credited with.<br />
<br />
You can manage all the ads you buy, by logging into your account at, <a href=$_config[www]>$_config[www]</a>
<br />
<br />
Regards<br />
<br />
$_config[website_name]<br />
$_config[www]<br />
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "To: $post[username]<$post[email]>" . "\r\n";
$headers .= "From: $_config[website_name]<$_config[admin_email]>" . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
}
if(isset($_POST[reject_edit])) {
mysql_query("update advertisersinfo_edit set approved='R' where adv_id='$_GET[adv_id]' ");
}
if(isset($_POST[reason])) {
if (mysql_query("update advertisersinfo set refuse_reason='$_POST[why]' where adv_id='$_GET[adv_id]' and pub_uid='$_SESSION[uid]' "))
header ("location: account.php?new_ads");
}
if(isset($_POST[approve])) {
if(mysql_query("update advertisersinfo set approved='Y' where adv_id='$_GET[adv_id]' and pub_uid='$_SESSION[uid]' and approved='N' and is_paid='Y' and is_auth='Y' ")) {
$price = mysql_fetch_assoc(mysql_query("select pid, price, ppc_balance from advertisersinfo where pub_uid='$_SESSION[uid]' and adv_id = '$_GET[adv_id]' and is_paid = 'Y' and is_auth='Y' and approved='Y'"));
$pid = $price[pid];
if($price[ppc_balance] == 0)
$cost = $price[price];
else $cost = $price[ppc_balance];
//// % calculation ... !!!
$percent = mysql_result(mysql_query("select pay_rate from publishersinfo where pid = '$pid'"),0,0);
if($percent == 0) $percent = $_config[default_pay_rate];
$pub_earning = round((($cost * $percent) / 100),2);
$admin_earning = $cost - $pub_earning;
mysql_query("update users set balance = ( balance + $pub_earning ) where uid='$_SESSION[uid]' ");
mysql_query("insert into admin_earnings set date = curdate() , earning = '$admin_earning' ");
}
$to = $post[email];
// subject
$subject = 'Ad Accepted';
// message
$message = "
<html>
<head>
<title>Ad Accepted</title>
</head>
<body>
Your ad for the following website has been accepted,<br />
<br />
Website: $pubname<br />
Ad Length: $adlen<br />
Ad Cost: $adcost<br />
Your ad is now live, and will run for the length of time you paid for.
<br />
<br />
<br />
You can manage all the ads you buy, by logging into your account at, <a href=$_config[www]>$_config[www]</a>
<br />
<br />
Regards<br />
<br />
$_config[website_name]<br />
$_config[www]<br />
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "To: $post[username]<$post[email]>" . "\r\n";
$headers .= "From: $_config[website_name]<$_config[admin_email]>" . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
}
if(isset($_POST[approve_edit])) {
mysql_query("update advertisersinfo_edit set approved='Y' where adv_id='$_GET[adv_id]' ");
$e = mysql_fetch_assoc(mysql_query("select * from advertisersinfo_edit where adv_id='$_GET[adv_id]' "));
mysql_query("update advertisersinfo set site_name='$e[site_name]',ad_hl='$e[ad_hl]', ad_des='$e[ad_des]', ad_url='$e[ad_url]', ad_img='$e[ad_img]', approved='Y' where adv_id='$_GET[adv_id]' and pub_uid='$_SESSION[uid]' ");
}
$res = mysql_fetch_assoc(mysql_query("select * from advertisersinfo where adv_id = '$_GET[adv_id]' and pub_uid='$_SESSION[uid]' and is_paid='Y' and is_auth='Y' "));
$smarty->assign('ad', $res);
$as = mysql_fetch_assoc(mysql_query("select * from publishers_adspaces where ad_id='$res[ad_id]'"));
$smarty->assign('ad_space', $as);
if($as['length'] == 0) {
$smarty->assign('price', $res['ppc_balance']);
if($res['ad_type'] == 'ppc_txt_ad')
$smarty->assign('product', ' Pay per Click Text Ad ');
if($res['ad_type'] == 'ppc_img_ad')
$smarty->assign('product', ' Pay per Click Image Ad ');
if($res['ad_type'] == 'ppc_vdo_ad')
$smarty->assign('product', ' Pay per Click Video Ad ');
}
else {
if($as[cost] != $res[price])
$smarty->assign('offer', 'Y');
$smarty->assign('price', $res['price']);
if($res['ad_type'] == 'txt_ad')
$smarty->assign('product', $as[length].' Day Text Ad ');
if($res['ad_type'] == 'img_ad')
$smarty->assign('product', $as[length].' Day Image Ad ');
if($res['ad_type'] == 'vdo_ad')
$smarty->assign('product', $as[length].' Day Video Ad ');
}
$user = mysql_result(mysql_query("select username from users where uid='$res[uid]' "),0,0);
$smarty->assign('user', $user);
if(isset($_REQUEST[edit])) {
unset($res); ////////////////////////////////
$res = mysql_fetch_assoc(mysql_query("select * from advertisersinfo_edit where adv_id = '$_GET[adv_id]' "));
$smarty->assign('new_hl', $res[ad_hl]);
$smarty->assign('new_des', $res[ad_des]);
$smarty->assign('new_url', $res[ad_url]);
}
if (file_exists($res['ad_img'])) {
$smarty->assign('has_file', 'Y');
$tmp = explode('.', $res['ad_img']);
$ext = $tmp[count($tmp)-1];
$smarty->assign('ext', $ext);
}
else $smarty->assign('has_file', 'N');
$sz = explode('x', $as['size']);
$smarty->assign('div_size', $sz);
$smarty->assign('right_panel', 'off');
$smarty->assign('swf_object', 'Y');
$content = $smarty->fetch('ads_approval.tpl');
$smarty->assign('content', $content);
$smarty->display('master_page.tpl');
?>