1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) 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 | ); |
---|
10 | |
---|
11 | |
---|
12 | load_language('plugin.lang', CRYPTO_PATH); |
---|
13 | |
---|
14 | |
---|
15 | if ( isset($_POST['submit'])) |
---|
16 | { |
---|
17 | $conf['cryptographp'] = array( |
---|
18 | 'activate_on' => array( |
---|
19 | 'picture' => isset($_POST['activate_on']['picture']), |
---|
20 | 'category' => isset($_POST['activate_on']['category']) || !$loaded['category'], |
---|
21 | 'register' => isset($_POST['activate_on']['register']), |
---|
22 | 'contactform' => isset($_POST['activate_on']['contactform']) || !$loaded['contactform'], |
---|
23 | 'guestbook' => isset($_POST['activate_on']['guestbook']) || !$loaded['guestbook'], |
---|
24 | ), |
---|
25 | 'comments_action' => $_POST['comments_action'], |
---|
26 | 'theme' => $_POST['theme'], |
---|
27 | 'captcha_type' => $_POST['captcha_type'], |
---|
28 | 'case_sensitive' => 'false', //not used, problem with some fonts |
---|
29 | 'width' => (int)$_POST['width'], |
---|
30 | 'height' => (int)$_POST['height'], |
---|
31 | 'perturbation' => (float)$_POST['perturbation'], |
---|
32 | 'image_bg_color' => $_POST['image_bg_color'], |
---|
33 | 'code_length' => (int)$_POST['code_length'], |
---|
34 | 'text_color' => $_POST['text_color'], |
---|
35 | 'num_lines' => (float)$_POST['num_lines'], |
---|
36 | 'line_color' => $_POST['line_color'], |
---|
37 | 'noise_level' => (float)$_POST['noise_level'], |
---|
38 | 'noise_color' => $_POST['noise_color'], |
---|
39 | 'ttf_file' => $_POST['ttf_file'], |
---|
40 | 'button_color' => $_POST['button_color'], |
---|
41 | ); |
---|
42 | |
---|
43 | conf_update_param('cryptographp', serialize($conf['cryptographp'])); |
---|
44 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
45 | } |
---|
46 | |
---|
47 | $presets = array( |
---|
48 | 'bluenoise' => array('perturbation'=>0.25, 'image_bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2, 'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'), |
---|
49 | 'gray' => array('perturbation'=>1, 'image_bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'), |
---|
50 | 'xcolor' => array('perturbation'=>0.5, 'image_bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2, 'noise_color'=>'ffffff', 'ttf_file'=>'Dread'), |
---|
51 | 'pencil' => array('perturbation'=>0.8, 'image_bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'), |
---|
52 | ); |
---|
53 | |
---|
54 | function list_fonts($dir) |
---|
55 | { |
---|
56 | $dir = rtrim($dir, '/'); |
---|
57 | $dh = opendir($dir); |
---|
58 | $fonts = array(); |
---|
59 | |
---|
60 | while (($file = readdir($dh)) !== false ) |
---|
61 | { |
---|
62 | if ($file !== '.' && $file !== '..') $fonts[] = str_replace('.ttf', null, $file); |
---|
63 | } |
---|
64 | |
---|
65 | closedir($dh); |
---|
66 | return $fonts; |
---|
67 | } |
---|
68 | |
---|
69 | function presets_to_js($presets) |
---|
70 | { |
---|
71 | $out = null; |
---|
72 | |
---|
73 | foreach ($presets as $name => $param) |
---|
74 | { |
---|
75 | $out.= ' |
---|
76 | function apply_'.$name.'() { |
---|
77 | $("input[name=perturbation]").val("'.$param['perturbation'].'"); |
---|
78 | $("input[name=image_bg_color]").val("'.$param['image_bg_color'].'"); |
---|
79 | $("input[name=text_color]").val("'.$param['text_color'].'"); |
---|
80 | $("input[name=num_lines]").val("'.$param['num_lines'].'"); |
---|
81 | $("input[name=line_color]").val("'.$param['line_color'].'"); |
---|
82 | $("input[name=noise_level]").val("'.$param['noise_level'].'"); |
---|
83 | $("input[name=noise_color]").val("'.$param['noise_color'].'"); |
---|
84 | $("input[name=ttf_file]").val(["'.$param['ttf_file'].'"]); |
---|
85 | }'; |
---|
86 | } |
---|
87 | |
---|
88 | return $out; |
---|
89 | } |
---|
90 | |
---|
91 | $template->assign(array( |
---|
92 | 'crypto' => $conf['cryptographp'], |
---|
93 | 'loaded' => $loaded, |
---|
94 | 'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), |
---|
95 | 'presets' => array_keys($presets), |
---|
96 | 'PRESETS_FUNC' => presets_to_js($presets), |
---|
97 | 'CRYPTO_PATH' => CRYPTO_PATH, |
---|
98 | )); |
---|
99 | |
---|
100 | $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl'); |
---|
101 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
102 | |
---|
103 | ?> |
---|