1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // $conf['cryptographp'] = unserialize($conf['cryptographp']); |
---|
5 | load_language('plugin.lang', CRYPTO_PATH); |
---|
6 | |
---|
7 | if ( isset($_POST['submit'])) |
---|
8 | { |
---|
9 | $conf['cryptographp'] = array( |
---|
10 | 'comments_action' => $_POST['comments_action'], |
---|
11 | 'theme' => $_POST['theme'], |
---|
12 | 'captcha_type' => $_POST['captcha_type'], |
---|
13 | 'case_sensitive' => $conf['cryptographp']['case_sensitive'], //not used, problem with some fonts |
---|
14 | 'width' => (int)$_POST['width'], |
---|
15 | 'height' => (int)$_POST['height'], |
---|
16 | 'perturbation' => (float)$_POST['perturbation'], |
---|
17 | 'image_bg_color' => $_POST['image_bg_color'], |
---|
18 | 'code_length' => (int)$_POST['code_length'], |
---|
19 | 'text_color' => $_POST['text_color'], |
---|
20 | 'num_lines' => (float)$_POST['num_lines'], |
---|
21 | 'line_color' => $_POST['line_color'], |
---|
22 | 'noise_level' => (float)$_POST['noise_level'], |
---|
23 | 'noise_color' => $_POST['noise_color'], |
---|
24 | 'ttf_file' => $_POST['ttf_file'], |
---|
25 | ); |
---|
26 | |
---|
27 | conf_update_param('cryptographp', serialize($conf['cryptographp'])); |
---|
28 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
29 | } |
---|
30 | |
---|
31 | $presets = array( |
---|
32 | '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'), |
---|
33 | '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'), |
---|
34 | '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'), |
---|
35 | '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'), |
---|
36 | ); |
---|
37 | |
---|
38 | function list_fonts($dir) |
---|
39 | { |
---|
40 | $dir = rtrim($dir, '/'); |
---|
41 | $dh = opendir($dir); |
---|
42 | $fonts = array(); |
---|
43 | |
---|
44 | while (($file = readdir($dh)) !== false ) |
---|
45 | { |
---|
46 | if ($file !== '.' && $file !== '..') $fonts[] = str_replace('.ttf', null, $file); |
---|
47 | } |
---|
48 | |
---|
49 | closedir($dh); |
---|
50 | return $fonts; |
---|
51 | } |
---|
52 | |
---|
53 | function presets_to_js($presets) |
---|
54 | { |
---|
55 | $out = null; |
---|
56 | |
---|
57 | foreach ($presets as $name => $param) |
---|
58 | { |
---|
59 | $out.= ' |
---|
60 | function apply_'.$name.'() { |
---|
61 | $("input[name=perturbation]").val("'.$param['perturbation'].'"); |
---|
62 | $("input[name=image_bg_color]").val("'.$param['image_bg_color'].'"); |
---|
63 | $("input[name=text_color]").val("'.$param['text_color'].'"); |
---|
64 | $("input[name=num_lines]").val("'.$param['num_lines'].'"); |
---|
65 | $("input[name=line_color]").val("'.$param['line_color'].'"); |
---|
66 | $("input[name=noise_level]").val("'.$param['noise_level'].'"); |
---|
67 | $("input[name=noise_color]").val("'.$param['noise_color'].'"); |
---|
68 | $("input[name=ttf_file]").val(["'.$param['ttf_file'].'"]); |
---|
69 | |
---|
70 | }'; |
---|
71 | } |
---|
72 | |
---|
73 | return $out; |
---|
74 | } |
---|
75 | |
---|
76 | $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl'); |
---|
77 | |
---|
78 | $template->assign(array( |
---|
79 | 'crypto' => $conf['cryptographp'], |
---|
80 | 'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), |
---|
81 | 'presets' => array_keys($presets), |
---|
82 | 'PRESETS_FUNC' => presets_to_js($presets), |
---|
83 | 'CRYPTO_PATH' => CRYPTO_PATH, |
---|
84 | )); |
---|
85 | |
---|
86 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
87 | |
---|
88 | ?> |
---|