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
RevLine 
[10837]1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
[15996]4global $pwg_loaded_plugins;
[19428]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  );
[15996]10
[19428]11
[10837]12load_language('plugin.lang', CRYPTO_PATH);
13
[19428]14
[10837]15if ( isset($_POST['submit']))
[19428]16{ 
[12617]17  $conf['cryptographp'] = array(
[15996]18    'activate_on'     => array(
[23209]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'],
[15996]24          ),
[12617]25    'comments_action' => $_POST['comments_action'],
26    'theme'           => $_POST['theme'],
27    'captcha_type'    => $_POST['captcha_type'],
[14527]28    'case_sensitive'  => 'false', //not used, problem with some fonts
[12617]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'],
[19428]40    'button_color'    => $_POST['button_color'],
[11316]41    );
[12617]42 
43  conf_update_param('cryptographp', serialize($conf['cryptographp']));
[10837]44  array_push($page['infos'], l10n('Information data registered in database'));
45}
46
[12617]47$presets = array(
[14527]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'),
[12617]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  {
[22725]62    if ($file !== '.' && $file !== '..' && get_extension($file)=='ttf') 
63      $fonts[] = get_filename_wo_extension($file);
[12617]64  }
65 
66  closedir($dh);
67  return $fonts;
68}
[10837]69
70$template->assign(array(
[12617]71  'crypto' => $conf['cryptographp'],
[15996]72  'loaded' => $loaded,
[12617]73  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
[23209]74  'PRESETS' => $presets,
[10837]75  'CRYPTO_PATH' => CRYPTO_PATH,
[12617]76  ));
[10837]77
[15996]78$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
[11316]79$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
[10837]80
81?>
Note: See TracBrowser for help on using the repository browser.