1 | <?php |
---|
2 | defined('EASYCAPTCHA_ID') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $pwg_loaded_plugins; |
---|
5 | $loaded = array( |
---|
6 | 'contactform' => isset($pwg_loaded_plugins['ContactForm']), |
---|
7 | 'category' => isset($pwg_loaded_plugins['Comments_on_Albums']), |
---|
8 | 'guestbook' => isset($pwg_loaded_plugins['GuestBook']), |
---|
9 | 'cryptocaptcha' => isset($pwg_loaded_plugins['CryptograPHP']), |
---|
10 | ); |
---|
11 | |
---|
12 | if ($loaded['cryptocaptcha']) |
---|
13 | { |
---|
14 | $page['warnings'][] = l10n('We detected that Crypto Captcha plugin is available on your gallery. Both plugins can be used at the same time, but you should not under any circumstances activate both of them on the same page.'); |
---|
15 | } |
---|
16 | |
---|
17 | if (isset($_POST['submit'])) |
---|
18 | { |
---|
19 | if (!isset($_POST['activate_on'])) $_POST['activate_on'] = array(); |
---|
20 | |
---|
21 | $conf['EasyCaptcha'] = array( |
---|
22 | 'activate_on' => array( |
---|
23 | 'picture' => in_array('picture', $_POST['activate_on']), |
---|
24 | 'category' => in_array('category', $_POST['activate_on']) || !$loaded['category'], |
---|
25 | 'register' => in_array('register', $_POST['activate_on']), |
---|
26 | 'contactform' => in_array('contactform', $_POST['activate_on']) || !$loaded['contactform'], |
---|
27 | 'guestbook' => in_array('guestbook', $_POST['activate_on']) || !$loaded['guestbook'], |
---|
28 | ), |
---|
29 | 'comments_action' => $_POST['comments_action'], |
---|
30 | 'guest_only' => isset($_POST['guest_only']), |
---|
31 | 'challenge' => $_POST['challenge'], |
---|
32 | 'drag' => array( |
---|
33 | 'theme' => $_POST['drag']['theme'], |
---|
34 | 'size' => (int)$_POST['drag']['size'], |
---|
35 | 'nb' => (int)$_POST['drag']['nb'], |
---|
36 | 'bg1' => check_color($_POST['drag']['bg1']), |
---|
37 | 'bg2' => check_color($_POST['drag']['bg2']), |
---|
38 | 'obj' => check_color($_POST['drag']['obj']), |
---|
39 | 'sel' => check_color($_POST['drag']['sel']), |
---|
40 | 'bd1' => check_color($_POST['drag']['bd1']), |
---|
41 | 'bd2' => check_color($_POST['drag']['bd2']), |
---|
42 | 'txt' => check_color($_POST['drag']['txt']), |
---|
43 | ), |
---|
44 | 'tictac' => array( |
---|
45 | 'size' => (int)$_POST['tictac']['size'], |
---|
46 | 'bg1' => check_color($_POST['tictac']['bg1']), |
---|
47 | 'bg2' => check_color($_POST['tictac']['bg2']), |
---|
48 | 'bd' => check_color($_POST['tictac']['bd']), |
---|
49 | 'obj' => check_color($_POST['tictac']['obj']), |
---|
50 | 'sel' => check_color($_POST['tictac']['sel']), |
---|
51 | ), |
---|
52 | 'lastmod' => time(), |
---|
53 | ); |
---|
54 | |
---|
55 | conf_update_param('EasyCaptcha', $conf['EasyCaptcha']); |
---|
56 | $page['infos'][] = l10n('Information data registered in database'); |
---|
57 | } |
---|
58 | |
---|
59 | function list_themes($dir) |
---|
60 | { |
---|
61 | $dir = rtrim($dir, '/'); |
---|
62 | $dh = opendir($dir); |
---|
63 | $themes = array(); |
---|
64 | |
---|
65 | while (($item = readdir($dh)) !== false ) |
---|
66 | { |
---|
67 | if ($item!=='.' && $item!=='..' && |
---|
68 | is_dir($dir.'/'.$item) && file_exists($dir.'/'.$item.'/conf.inc.php') |
---|
69 | ) |
---|
70 | { |
---|
71 | $drag_images = include($dir.'/'.$item.'/conf.inc.php'); |
---|
72 | $themes[$item] = array( |
---|
73 | 'image' => key($drag_images), |
---|
74 | 'count' => count($drag_images), |
---|
75 | ); |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | closedir($dh); |
---|
80 | return $themes; |
---|
81 | } |
---|
82 | |
---|
83 | $template->assign(array( |
---|
84 | 'easycaptcha' => $conf['EasyCaptcha'], |
---|
85 | 'loaded' => $loaded, |
---|
86 | 'THEMES' => list_themes(EASYCAPTCHA_PATH . 'drag'), |
---|
87 | 'EASYCAPTCHA_PATH' => EASYCAPTCHA_PATH, |
---|
88 | 'EASYCAPTCHA_ABS_PATH' => realpath(EASYCAPTCHA_PATH) . '/', |
---|
89 | 'DRAG_CSS' => file_get_contents(EASYCAPTCHA_PATH . 'template/drag.css'), |
---|
90 | )); |
---|
91 | |
---|
92 | $template->set_filename('plugin_admin_content', realpath(EASYCAPTCHA_PATH . 'template/admin.tpl')); |
---|
93 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
94 | |
---|
95 | |
---|
96 | function check_color($hex) |
---|
97 | { |
---|
98 | global $page; |
---|
99 | |
---|
100 | $hex = ltrim($hex, '#'); |
---|
101 | |
---|
102 | if (strlen($hex) == 3) |
---|
103 | { |
---|
104 | $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; |
---|
105 | } |
---|
106 | else if (strlen($hex) != 6 || !ctype_xdigit($hex)) |
---|
107 | { |
---|
108 | $page['errors'][] = l10n('Invalid color code <i>%s</i>', '#'.$hex); |
---|
109 | $hex = '000000'; |
---|
110 | } |
---|
111 | |
---|
112 | return '#'.$hex; |
---|
113 | } |
---|