-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.php
67 lines (58 loc) · 2.32 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
defined('COLOR_PALETTE_PATH') or die('Hacking attempt!');
global $template, $page, $conf;
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'config';
$tabsheet = new tabsheet();
$tabsheet->add('config', l10n('Configuration'), COLOR_PALETTE_ADMIN.'-config');
$tabsheet->select($page['tab']);
$tabsheet->assign();
if (isset($_POST['submit']))
{
check_pwg_token();
$old_conf = $conf;
$colors = isset($_POST['colors']) ? (intval($_POST['colors'])) : $old_conf['colors'];
if (($colors < 3) || ($colors > 16))
{
$page['errors'][] = l10n('Number of colors must have a value between %d and %d', 3, 16);
$colors = $old_conf['colors'];
}
$sample_size = isset($_POST['sample_size']) ? (intval($_POST['sample_size'])) : $old_conf['sample_size'];
if (($sample_size < 50) || ($sample_size > 400))
{
$page['errors'][] = l10n('Sample image must have a size between %d and %d', 50, 400);
$sample_size = $old_conf['sample_size'];
}
$coverage = isset($_POST['coverage']) ? (intval($_POST['coverage'])) : $old_conf['coverage'];
print_r($coverage);
if (($coverage < 30) || ($coverage > 100))
{
$page['errors'][] = l10n('Sample image coverage must have a value between %d and %d', 30, 100);
$coverage = $old_conf['coverage'];
}
if (empty($page['errors']))
{
$conf['ColorPalette'] = array(
'colors' => $colors,
'sample_size' => $sample_size,
'coverage' => $coverage,
'generate_on_image_page' => isset($_POST['generate_on_image_page'])
);
if (isset($_POST['clear']))
{
pwg_query('TRUNCATE `'. COLOR_PALETTE_TABLE .'`;');
}
conf_update_param('ColorPalette', serialize($conf['ColorPalette']));
$page['infos'][] = l10n('Configuration successfully updated');
}
}
$template->assign(array(
'COLOR_PALETTE_PATH' => COLOR_PALETTE_PATH,
'COLOR_PALETTE_ADMIN' => COLOR_PALETTE_ADMIN,
'COLOR_PALETTE_DEFAULT_COLORS' => COLOR_PALETTE_DEFAULT_COLORS,
'COLOR_PALETTE_DEFAULT_SAMPLE_SIZE' => COLOR_PALETTE_DEFAULT_SAMPLE_SIZE,
'ColorPalette' => $conf['ColorPalette'],
'PWG_TOKEN' => get_pwg_token()
));
$template->set_filename('plugin_admin_content', realpath(COLOR_PALETTE_PATH . 'template/admin.tpl'));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');