source: extensions/BanIP/admin.php @ 31373

Last change on this file since 31373 was 31373, checked in by ddtddt, 8 years ago

[extensions] - BanIP - check language

File size: 4.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Ban IP plugin for piwigo                                              |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2016 ddtddt                            http://temmii.com |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License as published by  |
9// | the Free Software Foundation                                          |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21
22if (!defined('PHPWG_ROOT_PATH'))
23    die('Hacking attempt!');
24global $template, $conf, $user;
25include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php');
26load_language('plugin.lang', BANIP_PATH);
27$my_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugin-';
28
29// +-----------------------------------------------------------------------+
30// | Check Access and exit when user status is not ok                      |
31// +-----------------------------------------------------------------------+
32check_status(ACCESS_ADMINISTRATOR);
33
34//-------------------------------------------------------- sections definitions
35if (!isset($_GET['tab']))
36    $page['tab'] = 'banip';
37else
38    $page['tab'] = $_GET['tab'];
39
40
41
42    $tabsheet = new tabsheet();
43    $tabsheet->add('banip', l10n('IP ban'), BANIP_ADMIN . '-banip');
44    $tabsheet->select($page['tab']);
45    $tabsheet->assign();
46
47switch ($page['tab']) {
48    case 'banip':
49          $template->assign(
50       'ipbangest', array(
51       'A' => 'a'
52    ));
53        $ipban = pwg_query("SELECT * FROM " . BANIP_TABLE . ";");
54       
55        $template->func_combine_css(array('id'=>'dst','path'=>BANIP_PATH.'banip.css'));
56       
57    $admin_base_url = BANIP_ADMIN . '-banip';
58        if (pwg_db_num_rows($ipban)) {
59            while ($ipban2 = pwg_db_fetch_assoc($ipban)) {
60                               
61                $items = array(
62                    'ID' => $ipban2['id'],
63                    'IP' => $ipban2['ip'],
64                    'U_DELETE' => $admin_base_url . '&amp;delete=' . $ipban2['id'],
65                    'U_EDIT' => $admin_base_url . '&amp;edit=' . $ipban2['id'],
66                );
67
68                $template->append('ipban2', $items);
69            }
70        }
71               
72  if (isset($_GET['delete'])) {
73
74    check_input_parameter('delete', $_GET, false, PATTERN_ID);
75    $query = 'DELETE FROM ' . BANIP_TABLE . ' WHERE id = ' . $_GET['delete'] . ';';
76    pwg_query($query);
77
78    $_SESSION['page_infos'] = array(l10n('IP ban deleted'));
79    redirect($admin_base_url);
80  }
81
82if (isset($_GET['edit'])) {
83    check_input_parameter('edit', $_GET, false, PATTERN_ID);
84    $query = 'SELECT * FROM ' . BANIP_TABLE . ' WHERE id = \'' . $_GET['edit'] . '\';';
85                $result = pwg_query($query);
86                $row = pwg_db_fetch_assoc($result);
87                $template->assign(
88                        'ipban_edit', array(
89                        'ID' => $row['id'],
90                        'IP' => $row['ip'],
91                ));
92} 
93
94if (isset($_POST['submitaddipban2'])) {
95        $query = 'UPDATE ' . BANIP_TABLE .' SET ip= "'.$_POST['inserip'].'" WHERE id = '.$_POST['invisibleID'].';';
96        $result = pwg_query($query);
97        $_SESSION['page_infos'] = array(l10n('Ip ban update'));
98        redirect($admin_base_url);
99}
100
101//add ban
102if (isset($_POST['submitipban'])) {
103        $template->assign(
104                'ipban_add', array(
105                'nada' => l10n('nada'),
106        ));
107        $template->clear_assign(
108                'ipban_edit', array(
109        ));
110}
111
112if (isset($_POST['submitaddipban'])) {
113        $query = 'INSERT INTO ' . BANIP_TABLE .'(ip) VALUES ("' . $_POST['inserip'] . '");';
114        $result = pwg_query($query);
115        $_SESSION['page_infos'] = array(l10n('Ip ban insert'));
116        redirect($admin_base_url);
117}
118               
119       
120        break;
121}
122       
123
124$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
125$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
126?>
Note: See TracBrowser for help on using the repository browser.