source: extensions/CryptograPHP/admin.php @ 23209

Last change on this file since 23209 was 23209, checked in by mistic100, 11 years ago

rewrite config page

File size: 3.3 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) 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  );
10
11
12load_language('plugin.lang', CRYPTO_PATH);
13
14
15if ( isset($_POST['submit']))
16{ 
17  $conf['cryptographp'] = array(
18    'activate_on'     => array(
19          'picture'     => in_array('picture', $_POST['activate_on']),
20          'category'    => in_array('category', $_POST['activate_on']) || !$loaded['category'],
21          'register'    => in_array('register', $_POST['activate_on']),
22          'contactform' => in_array('contactform', $_POST['activate_on']) || !$loaded['contactform'],
23          'guestbook'   => in_array('guestbook', $_POST['activate_on']) || !$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 
54function 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 !== '..' && get_extension($file)=='ttf') 
63      $fonts[] = get_filename_wo_extension($file);
64  }
65 
66  closedir($dh);
67  return $fonts;
68}
69
70$template->assign(array(
71  'crypto' => $conf['cryptographp'],
72  'loaded' => $loaded,
73  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
74  'PRESETS' => $presets,
75  'CRYPTO_PATH' => CRYPTO_PATH,
76  ));
77
78$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
79$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
80
81?>
Note: See TracBrowser for help on using the repository browser.