hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
mattice
|
151
|
3
|
$Id: banner_manager.php 901 2006-08-30 17:08:05Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
410
|
8
|
Copyright (c) 2006 osCommerce
|
hpdl
|
1
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
|
13
|
require('includes/application_top.php');
|
|
14
|
|
|
15
|
$action = (isset($_GET['action']) ? $_GET['action'] : '');
|
|
16
|
|
|
17
|
if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
|
|
18
|
$_GET['page'] = 1;
|
|
19
|
}
|
|
20
|
|
hpdl
|
758
|
21
|
$image_extension = osc_dynamic_image_extension();
|
hpdl
|
1
|
22
|
|
|
23
|
if (!empty($action)) {
|
|
24
|
switch ($action) {
|
|
25
|
case 'save':
|
|
26
|
$banner_error = false;
|
|
27
|
|
|
28
|
if (empty($_POST['banners_title'])) {
|
|
29
|
$osC_MessageStack->add('header', ERROR_BANNER_TITLE_REQUIRED, 'error');
|
|
30
|
$banner_error = true;
|
|
31
|
}
|
|
32
|
|
hpdl
|
901
|
33
|
if (empty($_POST['banners_group']) && empty($_POST['new_banners_group'])) {
|
hpdl
|
1
|
34
|
$osC_MessageStack->add('header', ERROR_BANNER_GROUP_REQUIRED, 'error');
|
|
35
|
$banner_error = true;
|
|
36
|
}
|
|
37
|
|
|
38
|
if (empty($_POST['banners_html_text'])) {
|
|
39
|
if (empty($_POST['banners_image_local'])) {
|
hpdl
|
849
|
40
|
$banners_image = new upload('banners_image', realpath('../images/' . $_POST['banners_image_target']));
|
|
41
|
|
hpdl
|
901
|
42
|
if ($banners_image->exists()) {
|
|
43
|
if (!($banners_image->parse() && $banners_image->save())) {
|
hpdl
|
849
|
44
|
$banner_error = true;
|
|
45
|
}
|
hpdl
|
1
|
46
|
}
|
|
47
|
}
|
|
48
|
}
|
|
49
|
|
|
50
|
if ($banner_error === false) {
|
|
51
|
$db_image_location = (!empty($_POST['banners_image_local'])) ? $_POST['banners_image_local'] : $_POST['banners_image_target'] . $banners_image->filename;
|
|
52
|
|
|
53
|
if (isset($_GET['bID']) && is_numeric($_GET['bID'])) {
|
|
54
|
$Qbanner = $osC_Database->query('update :table_banners set banners_title = :banners_title, banners_url = :banners_url, banners_image = :banners_image, banners_group = :banners_group, banners_html_text = :banners_html_text, expires_date = :expires_date, expires_impressions = :expires_impressions, date_scheduled = :date_scheduled, status = :status where banners_id = :banners_id');
|
|
55
|
$Qbanner->bindInt(':banners_id', $_GET['bID']);
|
|
56
|
} else {
|
|
57
|
$Qbanner = $osC_Database->query('insert into :table_banners (banners_title, banners_url, banners_image, banners_group, banners_html_text, expires_date, expires_impressions, date_scheduled, status, date_added) values (:banners_title, :banners_url, :banners_image, :banners_group, :banners_html_text, :expires_date, :expires_impressions, :date_scheduled, :status, now())');
|
|
58
|
}
|
|
59
|
$Qbanner->bindTable(':table_banners', TABLE_BANNERS);
|
|
60
|
$Qbanner->bindValue(':banners_title', $_POST['banners_title']);
|
|
61
|
$Qbanner->bindValue(':banners_url', $_POST['banners_url']);
|
|
62
|
$Qbanner->bindValue(':banners_image', $db_image_location);
|
|
63
|
$Qbanner->bindValue(':banners_group', (!empty($_POST['new_banners_group']) ? $_POST['new_banners_group'] : $_POST['banners_group']));
|
|
64
|
$Qbanner->bindValue(':banners_html_text', $_POST['banners_html_text']);
|
|
65
|
|
|
66
|
if (empty($_POST['date_expires'])) {
|
|
67
|
$Qbanner->bindRaw(':expires_date', 'null');
|
|
68
|
$Qbanner->bindInt(':expires_impressions', $_POST['expires_impressions']);
|
|
69
|
} else {
|
|
70
|
$Qbanner->bindValue(':expires_date', $_POST['date_expires']);
|
|
71
|
$Qbanner->bindInt(':expires_impressions', '0');
|
|
72
|
}
|
|
73
|
|
|
74
|
if (empty($_POST['date_scheduled'])) {
|
|
75
|
$Qbanner->bindRaw(':date_scheduled', 'null');
|
|
76
|
$Qbanner->bindInt(':status', ((isset($_POST['status']) && ($_POST['status'] == 'on')) ? 1 : 0));
|
|
77
|
} else {
|
|
78
|
$Qbanner->bindValue(':date_scheduled', $_POST['date_scheduled']);
|
|
79
|
$Qbanner->bindInt(':status', ($_POST['date_scheduled'] > date('Y-m-d') ? 0 : ((isset($_POST['status']) && ($_POST['status'] == 'on')) ? 1 : 0)));
|
|
80
|
}
|
|
81
|
|
|
82
|
$Qbanner->execute();
|
|
83
|
|
|
84
|
if ($osC_Database->isError() === false) {
|
|
85
|
if (isset($_GET['bID']) && is_numeric($_GET['bID'])) {
|
|
86
|
$banners_id = $_GET['bID'];
|
|
87
|
} else {
|
|
88
|
$banners_id = $osC_Database->nextID();
|
|
89
|
}
|
|
90
|
|
|
91
|
$osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
|
|
92
|
} else {
|
|
93
|
$osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
|
94
|
}
|
|
95
|
|
hpdl
|
758
|
96
|
osc_redirect(osc_href_link_admin(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $banners_id));
|
hpdl
|
1
|
97
|
}
|
|
98
|
break;
|
|
99
|
case 'deleteconfirm':
|
|
100
|
if (isset($_GET['bID']) && is_numeric($_GET['bID'])) {
|
|
101
|
if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) {
|
|
102
|
$Qimage = $osC_Database->query('select banners_image from :table_banners where banners_id = :banners_id');
|
|
103
|
$Qimage->bindTable(':table_banners', TABLE_BANNERS);
|
|
104
|
$Qimage->bindInt(':banners_id', $_GET['bID']);
|
|
105
|
$Qimage->execute();
|
|
106
|
|
|
107
|
if (is_file('../images/' . $Qimage->value('banners_image'))) {
|
|
108
|
if (is_writeable('../images/' . $Qimage->value('banners_image'))) {
|
|
109
|
unlink('../images/' . $Qimage->value('banners_image'));
|
|
110
|
} else {
|
|
111
|
$osC_MessageStack->add_session('header', ERROR_IMAGE_IS_NOT_WRITEABLE, 'error');
|
|
112
|
}
|
|
113
|
} else {
|
|
114
|
$osC_MessageStack->add_session('header', ERROR_IMAGE_DOES_NOT_EXIST, 'error');
|
|
115
|
}
|
|
116
|
}
|
|
117
|
|
|
118
|
$Qdelete = $osC_Database->query('delete from :table_banners where banners_id = :banners_id');
|
|
119
|
$Qdelete->bindTable(':table_banners', TABLE_BANNERS);
|
|
120
|
$Qdelete->bindInt(':banners_id', $_GET['bID']);
|
|
121
|
$Qdelete->execute();
|
|
122
|
|
|
123
|
$Qdelete = $osC_Database->query('delete from :table_banners_history where banners_id = :banners_id');
|
|
124
|
$Qdelete->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
|
|
125
|
$Qdelete->bindInt(':banners_id', $_GET['bID']);
|
|
126
|
$Qdelete->execute();
|
|
127
|
|
|
128
|
if (!empty($image_extension)) {
|
|
129
|
if (is_file('images/graphs/banner_yearly-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
130
|
if (is_writeable('images/graphs/banner_yearly-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
131
|
unlink('images/graphs/banner_yearly-' . $_GET['bID'] . '.' . $image_extension);
|
|
132
|
}
|
|
133
|
}
|
|
134
|
|
|
135
|
if (is_file('images/graphs/banner_monthly-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
136
|
if (is_writeable('images/graphs/banner_monthly-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
137
|
unlink('images/graphs/banner_monthly-' . $_GET['bID'] . '.' . $image_extension);
|
|
138
|
}
|
|
139
|
}
|
|
140
|
|
|
141
|
if (is_file('images/graphs/banner_daily-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
142
|
if (is_writeable('images/graphs/banner_daily-' . $_GET['bID'] . '.' . $image_extension)) {
|
|
143
|
unlink('images/graphs/banner_daily-' . $_GET['bID'] . '.' . $image_extension);
|
|
144
|
}
|
|
145
|
}
|
|
146
|
}
|
|
147
|
|
|
148
|
$osC_MessageStack->add_session('header', SUCCESS_BANNER_REMOVED, 'success');
|
|
149
|
|
hpdl
|
758
|
150
|
osc_redirect(osc_href_link_admin(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page']));
|
hpdl
|
1
|
151
|
}
|
|
152
|
break;
|
|
153
|
}
|
|
154
|
}
|
|
155
|
|
|
156
|
// check if the graphs directory exists
|
|
157
|
$dir_ok = false;
|
|
158
|
if (!empty($image_extension)) {
|
|
159
|
if (is_dir('images/graphs')) {
|
|
160
|
if (is_writeable('images/graphs')) {
|
|
161
|
$dir_ok = true;
|
|
162
|
} else {
|
|
163
|
$osC_MessageStack->add('header', ERROR_GRAPHS_DIRECTORY_NOT_WRITEABLE, 'error');
|
|
164
|
}
|
|
165
|
} else {
|
|
166
|
$osC_MessageStack->add('header', ERROR_GRAPHS_DIRECTORY_DOES_NOT_EXIST, 'error');
|
|
167
|
}
|
|
168
|
}
|
|
169
|
|
|
170
|
switch ($action) {
|
|
171
|
case 'statistics': $page_contents = 'banner_manager_statistics.php'; break;
|
|
172
|
default: $page_contents = 'banner_manager.php';
|
|
173
|
}
|
|
174
|
|
|
175
|
require('templates/default.php');
|
|
176
|
|
|
177
|
require('includes/application_bottom.php');
|
|
178
|
?>
|