1 | <?php |
---|
2 | if (!defined('HEADER_MANAGER_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // change banner to last uploaded |
---|
5 | if ( pwg_get_session_var('added_banner')!==null and $conf['header_manager']['image']!='random' ) |
---|
6 | { |
---|
7 | $conf['header_manager']['image'] = pwg_get_session_var('added_banner'); |
---|
8 | conf_update_param('header_manager', serialize($conf['header_manager'])); |
---|
9 | pwg_unset_session_var('added_banner'); |
---|
10 | } |
---|
11 | |
---|
12 | |
---|
13 | // save config |
---|
14 | if (isset($_POST['save_config'])) |
---|
15 | { |
---|
16 | if ($_POST['display'] == 'with_text') |
---|
17 | { |
---|
18 | $conf['page_banner'] = $_POST['conf_page_banner']; |
---|
19 | conf_update_param('page_banner', $conf['page_banner']); |
---|
20 | } |
---|
21 | |
---|
22 | $conf['header_manager'] = array( |
---|
23 | 'width' => $conf['header_manager']['width'], |
---|
24 | 'height' => $conf['header_manager']['height'], |
---|
25 | 'image' => @$_POST['image'], |
---|
26 | 'display' => $_POST['display'], |
---|
27 | 'banner_on_picture' => isset($_POST['banner_on_picture']), |
---|
28 | ); |
---|
29 | conf_update_param('header_manager', serialize($conf['header_manager'])); |
---|
30 | |
---|
31 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | // delete banner |
---|
36 | if (isset($_GET['delete_banner'])) |
---|
37 | { |
---|
38 | $banner = get_banner($_GET['delete_banner']); |
---|
39 | if ( $banner !== false or @unlink($banner['PATH']) ) |
---|
40 | { |
---|
41 | @unlink($banner['THUMB']); |
---|
42 | |
---|
43 | if ($conf['header_manager']['image'] == $_GET['delete_banner']) |
---|
44 | { |
---|
45 | $conf['header_manager']['image'] = 'random'; |
---|
46 | conf_update_param('header_manager', serialize($conf['header_manager'])); |
---|
47 | } |
---|
48 | |
---|
49 | $query = ' |
---|
50 | DELETE FROM '.HEADER_MANAGER_TABLE.' |
---|
51 | WHERE image = "'.$_GET['delete_banner'].'" |
---|
52 | ;'; |
---|
53 | pwg_query($query); |
---|
54 | |
---|
55 | array_push($page['infos'], l10n('Banner deleted')); |
---|
56 | } |
---|
57 | else |
---|
58 | { |
---|
59 | array_push($page['warnings'], l10n('File/directory read error').' : ' . HEADER_MANAGER_DIR . $_GET['delete_banner']); |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | if (isset($_GET['delete_cat_banner'])) |
---|
64 | { |
---|
65 | $query = ' |
---|
66 | DELETE FROM '.HEADER_MANAGER_TABLE.' |
---|
67 | WHERE category_id = "'.$_GET['delete_cat_banner'].'" |
---|
68 | ;'; |
---|
69 | pwg_query($query); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | // album banners |
---|
74 | $query = ' |
---|
75 | SELECT |
---|
76 | id, |
---|
77 | name, |
---|
78 | permalink, |
---|
79 | dir, |
---|
80 | image, |
---|
81 | deep |
---|
82 | FROM '.HEADER_MANAGER_TABLE.' AS h |
---|
83 | INNER JOIN '.CATEGORIES_TABLE.' AS c |
---|
84 | ON h.category_id = c.id |
---|
85 | ORDER BY global_rank ASC |
---|
86 | ;'; |
---|
87 | $categories = hash_from_query($query, 'id'); |
---|
88 | |
---|
89 | foreach ($categories as $category) |
---|
90 | { |
---|
91 | $tpl_cat = |
---|
92 | array( |
---|
93 | 'NAME' => get_cat_display_name_from_id($category['id'], HEADER_MANAGER_ADMIN.'-album&cat_id='), |
---|
94 | 'ID' => $category['id'], |
---|
95 | 'IMAGE' => get_filename_wo_extension($category['image']), |
---|
96 | 'DEEP' => $category['deep'], |
---|
97 | 'U_DELETE' => HEADER_MANAGER_ADMIN.'-config&delete_cat_banner='.$category['id'], |
---|
98 | ); |
---|
99 | |
---|
100 | $template->append('categories', $tpl_cat); |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | // config template |
---|
105 | if ( empty($conf['header_manager']['image']) or get_banner($conf['header_manager']['image']) === false ) |
---|
106 | { |
---|
107 | $conf['header_manager']['image'] = 'random'; |
---|
108 | } |
---|
109 | |
---|
110 | $template->assign(array( |
---|
111 | 'banners' => list_banners(true), |
---|
112 | 'CONF_PAGE_BANNER' => stripslashes(htmlspecialchars($conf['page_banner'])), |
---|
113 | 'BANNER_IMAGE' => $conf['header_manager']['image'], |
---|
114 | 'BANNER_DISPLAY' => $conf['header_manager']['display'], |
---|
115 | 'BANNER_ON_PICTURE' => $conf['header_manager']['banner_on_picture'] |
---|
116 | )); |
---|
117 | |
---|
118 | $template->set_filename('header_manager', dirname(__FILE__).'/template/config.tpl'); |
---|
119 | |
---|
120 | ?> |
---|