source: extensions/CryptograPHP/admin.php @ 26072

Revision 26072, 3.6 KB checked in by mistic100, 6 years ago (diff)

try to simplify integration of captchas

Line 
1<?php
2defined('CRYPTO_ID') or die('Hacking attempt!');
3
4global $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
12if ($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
17if ( 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    'theme'           => $_POST['theme'],
31    'captcha_type'    => $_POST['captcha_type'],
32    'case_sensitive'  => 'false', //not used, problem with some fonts
33    'width'           => (int)$_POST['width'], 
34    'height'          => (int)$_POST['height'],
35    'perturbation'    => (float)$_POST['perturbation'],
36    'image_bg_color'  => $_POST['image_bg_color'],
37    'code_length'     => (int)$_POST['code_length'],
38    'text_color'      => $_POST['text_color'],
39    'num_lines'       => (float)$_POST['num_lines'],
40    'line_color'      => $_POST['line_color'],
41    'noise_level'     => (float)$_POST['noise_level'],
42    'noise_color'     => $_POST['noise_color'],
43    'ttf_file'        => $_POST['ttf_file'],
44    'button_color'    => $_POST['button_color'],
45    );
46 
47  conf_update_param('cryptographp', serialize($conf['cryptographp']));
48  $page['infos'][] = l10n('Information data registered in database');
49}
50
51$presets = array(
52  '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'),
53  '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'),
54  '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'),
55  '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'),
56  );
57 
58function list_fonts($dir)
59{
60  $dir = rtrim($dir, '/');
61  $dh = opendir($dir);
62  $fonts = array();
63 
64  while (($file = readdir($dh)) !== false )
65  {
66    if ($file !== '.' && $file !== '..' && get_extension($file)=='ttf') 
67      $fonts[] = get_filename_wo_extension($file);
68  }
69 
70  closedir($dh);
71  return $fonts;
72}
73
74$template->assign(array(
75  'crypto' => $conf['cryptographp'],
76  'loaded' => $loaded,
77  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
78  'PRESETS' => $presets,
79  'CRYPTO_PATH' => CRYPTO_PATH,
80  ));
81
82$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
83$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Note: See TracBrowser for help on using the repository browser.