source: extensions/header_manager/admin/config.php @ 30219

Last change on this file since 30219 was 29634, checked in by mistic100, 10 years ago

don't change banner to last uploaded

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