source: extensions/CryptograPHP/admin.php @ 22725

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

index.php was selectable as a font ! fix display of checkboxes with small browser window

File size: 4.1 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(
19          'picture'     => isset($_POST['activate_on']['picture']),
[19428]20          'category'    => isset($_POST['activate_on']['category']) || !$loaded['category'],
[15996]21          'register'    => isset($_POST['activate_on']['register']),
[19428]22          'contactform' => isset($_POST['activate_on']['contactform']) || !$loaded['contactform'],
23          'guestbook'   => isset($_POST['activate_on']['guestbook']) || !$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
[12617]70function presets_to_js($presets)
71{
72  $out = null;
73 
74  foreach ($presets as $name => $param)
75  {
76    $out.= '
77function apply_'.$name.'() {
78  $("input[name=perturbation]").val("'.$param['perturbation'].'");
79  $("input[name=image_bg_color]").val("'.$param['image_bg_color'].'");
80  $("input[name=text_color]").val("'.$param['text_color'].'");
81  $("input[name=num_lines]").val("'.$param['num_lines'].'");
82  $("input[name=line_color]").val("'.$param['line_color'].'");
83  $("input[name=noise_level]").val("'.$param['noise_level'].'");
84  $("input[name=noise_color]").val("'.$param['noise_color'].'");
85  $("input[name=ttf_file]").val(["'.$param['ttf_file'].'"]);
86}';
87  }
88   
89  return $out;
90}
91
[10837]92$template->assign(array(
[12617]93  'crypto' => $conf['cryptographp'],
[15996]94  'loaded' => $loaded,
[12617]95  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
96  'presets' => array_keys($presets),
97  'PRESETS_FUNC' => presets_to_js($presets),
[10837]98  'CRYPTO_PATH' => CRYPTO_PATH,
[12617]99  ));
[10837]100
[15996]101$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
[11316]102$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
[10837]103
104?>
Note: See TracBrowser for help on using the repository browser.