1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if (!defined("PHPWG_ROOT_PATH")){ |
---|
25 | die("Hacking attempt!"); |
---|
26 | } |
---|
27 | |
---|
28 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
29 | load_language('plugin.lang', COPYRIGHTS_PATH); |
---|
30 | |
---|
31 | // Check access and exit when user status is not ok |
---|
32 | check_status(ACCESS_ADMINISTRATOR); |
---|
33 | |
---|
34 | // Default is to create, if changed to 1, show edit page |
---|
35 | $edit = 0; |
---|
36 | |
---|
37 | // The values for the form fields |
---|
38 | $CRid = 0; |
---|
39 | $CRname = ''; |
---|
40 | $CRurl = ''; |
---|
41 | $CRdescr = ''; |
---|
42 | $CRvisible = 0; |
---|
43 | |
---|
44 | // Do managing of copyrights |
---|
45 | if (isset($_GET['tab'])) { |
---|
46 | if ($_GET['tab'] == 'create') { |
---|
47 | $name = pwg_db_real_escape_string($_REQUEST['name']); |
---|
48 | $url = pwg_db_real_escape_string($_REQUEST['url']); |
---|
49 | $descr = pwg_db_real_escape_string($_REQUEST['descr']); |
---|
50 | $visible = (isset($_REQUEST['visible']) ? 1 : 0); |
---|
51 | $query = sprintf( |
---|
52 | 'INSERT INTO %s |
---|
53 | (`name`,`url`,`descr`,`visible`) VALUES |
---|
54 | ("%s","%s","%s",%d) |
---|
55 | ;', |
---|
56 | COPYRIGHTS_ADMIN, $name, $url, $descr, $visible); |
---|
57 | pwg_query($query); |
---|
58 | } |
---|
59 | |
---|
60 | if ($_GET['tab'] == 'edit') { |
---|
61 | $edit = 1; |
---|
62 | $CRid = $_REQUEST['id']; |
---|
63 | $query = sprintf( |
---|
64 | 'SELECT * |
---|
65 | FROM %s |
---|
66 | WHERE `cr_id`=%d |
---|
67 | ;', |
---|
68 | COPYRIGHTS_ADMIN, $CRid); |
---|
69 | $result = pwg_query($query); |
---|
70 | $row = pwg_db_fetch_assoc($result); |
---|
71 | $CRname = $row['name']; |
---|
72 | $CRurl = $row['url']; |
---|
73 | $CRdescr = $row['descr']; |
---|
74 | $CRvisible = $row['visible']; |
---|
75 | } |
---|
76 | |
---|
77 | if ($_GET['tab'] == 'update') { |
---|
78 | $id = pwg_db_real_escape_string($_REQUEST['id']); |
---|
79 | $name = pwg_db_real_escape_string($_REQUEST['name']); |
---|
80 | $url = pwg_db_real_escape_string($_REQUEST['url']); |
---|
81 | $descr= pwg_db_real_escape_string($_REQUEST['descr']); |
---|
82 | $visible = (isset($_REQUEST['visible']) ? 1 : 0); |
---|
83 | $query = sprintf( |
---|
84 | 'UPDATE %s |
---|
85 | SET `name`="%s", `url`="%s", `descr`="%s", `visible`=%d |
---|
86 | WHERE `cr_id`=%d |
---|
87 | ;', |
---|
88 | COPYRIGHTS_ADMIN, $name, $url, $descr, $visible, $id); |
---|
89 | pwg_query($query); |
---|
90 | } |
---|
91 | |
---|
92 | if ($_GET['tab'] == 'delete') { |
---|
93 | $id = $_REQUEST['id']; |
---|
94 | $query = sprintf( |
---|
95 | 'DELETE FROM %s |
---|
96 | WHERE `cr_id`=%d |
---|
97 | ;', |
---|
98 | COPYRIGHTS_ADMIN, $id); |
---|
99 | pwg_query($query); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | // Create page template |
---|
104 | global $template; |
---|
105 | |
---|
106 | $template->set_filenames( |
---|
107 | array( |
---|
108 | 'plugin_admin_content' => dirname(__FILE__).'/admin.tpl' |
---|
109 | ) |
---|
110 | ); |
---|
111 | |
---|
112 | $query = sprintf( |
---|
113 | 'SELECT * |
---|
114 | FROM %s |
---|
115 | ;', |
---|
116 | COPYRIGHTS_ADMIN); |
---|
117 | $result = pwg_query($query); |
---|
118 | |
---|
119 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
120 | $template->append( |
---|
121 | 'CRs', |
---|
122 | array( |
---|
123 | 'cr_id' => $row['cr_id'], |
---|
124 | 'name' => $row['name'], |
---|
125 | 'url' => $row['url'], |
---|
126 | 'descr' => $row['descr'], |
---|
127 | 'visible' => $row['visible'] |
---|
128 | ) |
---|
129 | ); |
---|
130 | } |
---|
131 | |
---|
132 | $template->assign( |
---|
133 | 'COPYRIGHTS_PATH', |
---|
134 | COPYRIGHTS_WEB_PATH |
---|
135 | ); |
---|
136 | |
---|
137 | $template->assign('edit', $edit); |
---|
138 | $template->assign('CRid', $CRid); |
---|
139 | $template->assign('CRname', $CRname); |
---|
140 | $template->assign('CRurl', $CRurl); |
---|
141 | $template->assign('CRdescr', $CRdescr); |
---|
142 | $template->assign('CRvisible', $CRvisible); |
---|
143 | |
---|
144 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
145 | |
---|
146 | ?> |
---|