1 | <?php |
---|
2 | defined('CRYPTO_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 | 'easycaptcha' => isset($pwg_loaded_plugins['EasyCaptcha']), |
---|
10 | ); |
---|
11 | |
---|
12 | if ($loaded['easycaptcha']) |
---|
13 | { |
---|
14 | $page['warnings'][] = l10n('We detected that EasyCaptcha 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['cryptographp'] = 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 | 'theme' => $_POST['theme'], |
---|
32 | 'captcha_type' => $_POST['captcha_type'], |
---|
33 | 'case_sensitive' => 'false', //not used, problem with some fonts |
---|
34 | 'width' => (int)$_POST['width'], |
---|
35 | 'height' => (int)$_POST['height'], |
---|
36 | 'perturbation' => (float)$_POST['perturbation'], |
---|
37 | 'background' => $_POST['background'], |
---|
38 | 'bg_color' => $_POST['bg_color'], |
---|
39 | 'bg_image' => $_POST['bg_image'], |
---|
40 | 'code_length' => (int)$_POST['code_length'], |
---|
41 | 'text_color' => $_POST['text_color'], |
---|
42 | 'num_lines' => (float)$_POST['num_lines'], |
---|
43 | 'line_color' => $_POST['line_color'], |
---|
44 | 'noise_level' => (float)$_POST['noise_level'], |
---|
45 | 'noise_color' => $_POST['noise_color'], |
---|
46 | 'ttf_file' => $_POST['ttf_file'], |
---|
47 | 'button_color' => $_POST['button_color'], |
---|
48 | ); |
---|
49 | |
---|
50 | conf_update_param('cryptographp', $conf['cryptographp']); |
---|
51 | $page['infos'][] = l10n('Information data registered in database'); |
---|
52 | } |
---|
53 | |
---|
54 | $presets = array( |
---|
55 | 'bluenoise' => array('perturbation'=>0.25, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2, 'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'), |
---|
56 | 'gray' => array('perturbation'=>1, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'), |
---|
57 | 'xcolor' => array('perturbation'=>0.5, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2, 'noise_color'=>'ffffff', 'ttf_file'=>'Dread'), |
---|
58 | 'pencil' => array('perturbation'=>0.8, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'), |
---|
59 | 'ransom' => array('perturbation'=>0, 'background'=>'image', 'bg_image'=>'bg1.jpg', 'bg_color'=>'ffffff', 'text_color'=>'4a003a', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'ransom'), |
---|
60 | ); |
---|
61 | |
---|
62 | |
---|
63 | $template->assign(array( |
---|
64 | 'crypto' => $conf['cryptographp'], |
---|
65 | 'loaded' => $loaded, |
---|
66 | 'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), |
---|
67 | 'backgrounds' => list_backgrounds(CRYPTO_PATH.'securimage/backgrounds'), |
---|
68 | 'PRESETS' => $presets, |
---|
69 | 'CRYPTO_PATH' => CRYPTO_PATH, |
---|
70 | )); |
---|
71 | |
---|
72 | $template->set_filename('plugin_admin_content', realpath(CRYPTO_PATH . 'template/admin.tpl')); |
---|
73 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | function list_fonts($dir) |
---|
78 | { |
---|
79 | $dir = rtrim($dir, '/'); |
---|
80 | $dh = opendir($dir); |
---|
81 | $fonts = array(); |
---|
82 | |
---|
83 | while (($file = readdir($dh)) !== false ) |
---|
84 | { |
---|
85 | if ($file !== '.' && $file !== '..' && get_extension($file)=='ttf') |
---|
86 | { |
---|
87 | $fonts[get_filename_wo_extension($file)] = $dir . '/' . $file; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | closedir($dh); |
---|
92 | return $fonts; |
---|
93 | } |
---|
94 | |
---|
95 | function list_backgrounds($dir) |
---|
96 | { |
---|
97 | $dir = rtrim($dir, '/'); |
---|
98 | $dh = opendir($dir); |
---|
99 | $backgrounds = array(); |
---|
100 | |
---|
101 | while (($file = readdir($dh)) !== false ) |
---|
102 | { |
---|
103 | if ($file !== '.' && $file !== '..') |
---|
104 | { |
---|
105 | $ext = get_extension($file); |
---|
106 | if ($ext=='jpg' || $ext=='png' || $ext=='jpeg' || $ext=='gif') |
---|
107 | { |
---|
108 | $backgrounds[$file] = $dir . '/' . $file; |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | closedir($dh); |
---|
114 | return $backgrounds; |
---|
115 | } |
---|