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 | 'challenge' => $_POST['challenge'], |
---|
31 | 'drag' => array( |
---|
32 | 'theme' => $_POST['drag']['theme'], |
---|
33 | 'size' => (int)$_POST['drag']['size'], |
---|
34 | 'nb' => (int)$_POST['drag']['nb'], |
---|
35 | 'bg1' => check_color($_POST['drag']['bg1']), |
---|
36 | 'bg2' => check_color($_POST['drag']['bg2']), |
---|
37 | 'obj' => check_color($_POST['drag']['obj']), |
---|
38 | 'sel' => check_color($_POST['drag']['sel']), |
---|
39 | 'bd1' => check_color($_POST['drag']['bd1']), |
---|
40 | 'bd2' => check_color($_POST['drag']['bd2']), |
---|
41 | 'txt' => check_color($_POST['drag']['txt']), |
---|
42 | ), |
---|
43 | 'tictac' => array( |
---|
44 | 'size' => (int)$_POST['tictac']['size'], |
---|
45 | 'bg1' => check_color($_POST['tictac']['bg1']), |
---|
46 | 'bg2' => check_color($_POST['tictac']['bg2']), |
---|
47 | 'bd' => check_color($_POST['tictac']['bd']), |
---|
48 | 'obj' => check_color($_POST['tictac']['obj']), |
---|
49 | 'sel' => check_color($_POST['tictac']['sel']), |
---|
50 | ), |
---|
51 | 'lastmod' => time(), |
---|
52 | ); |
---|
53 | |
---|
54 | conf_update_param('EasyCaptcha', serialize($conf['EasyCaptcha'])); |
---|
55 | $page['infos'][] = l10n('Information data registered in database'); |
---|
56 | } |
---|
57 | |
---|
58 | function list_themes($dir) |
---|
59 | { |
---|
60 | $dir = rtrim($dir, '/'); |
---|
61 | $dh = opendir($dir); |
---|
62 | $themes = array(); |
---|
63 | |
---|
64 | while (($item = readdir($dh)) !== false ) |
---|
65 | { |
---|
66 | if ($item!=='.' && $item!=='..' && |
---|
67 | is_dir($dir.'/'.$item) && file_exists($dir.'/'.$item.'/conf.inc.php') |
---|
68 | ) |
---|
69 | { |
---|
70 | $drag_images = include($dir.'/'.$item.'/conf.inc.php'); |
---|
71 | $themes[$item] = array( |
---|
72 | 'image' => key($drag_images), |
---|
73 | 'count' => count($drag_images), |
---|
74 | ); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | closedir($dh); |
---|
79 | return $themes; |
---|
80 | } |
---|
81 | |
---|
82 | $template->assign(array( |
---|
83 | 'easycaptcha' => $conf['EasyCaptcha'], |
---|
84 | 'loaded' => $loaded, |
---|
85 | 'THEMES' => list_themes(EASYCAPTCHA_PATH . 'drag'), |
---|
86 | 'EASYCAPTCHA_PATH' => EASYCAPTCHA_PATH, |
---|
87 | 'EASYCAPTCHA_ABS_PATH' => realpath(EASYCAPTCHA_PATH) . '/', |
---|
88 | 'DRAG_CSS' => file_get_contents(EASYCAPTCHA_PATH . 'template/drag.css'), |
---|
89 | )); |
---|
90 | |
---|
91 | $template->set_filename('plugin_admin_content', realpath(EASYCAPTCHA_PATH . 'template/admin.tpl')); |
---|
92 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
93 | |
---|
94 | |
---|
95 | function check_color($hex) |
---|
96 | { |
---|
97 | global $page; |
---|
98 | |
---|
99 | $hex = ltrim($hex, '#'); |
---|
100 | |
---|
101 | if (strlen($hex) == 3) |
---|
102 | { |
---|
103 | $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; |
---|
104 | } |
---|
105 | else if (strlen($hex) != 6 || !ctype_xdigit($hex)) |
---|
106 | { |
---|
107 | $page['errors'][] = l10n('Invalid color code <i>%s</i>', '#'.$hex); |
---|
108 | $hex = '000000'; |
---|
109 | } |
---|
110 | |
---|
111 | return '#'.$hex; |
---|
112 | } |
---|