source: extensions/CryptograPHP/admin.php @ 16859

Last change on this file since 16859 was 15996, checked in by mistic100, 12 years ago

-add support for Guestbook
-add individual activation for each module
-increase default size
-clean index.php

File size: 4.1 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $pwg_loaded_plugins;
5$loaded = array();
6if (isset($pwg_loaded_plugins['ContactForm'])) $loaded['contactform'] = true;
7if (isset($pwg_loaded_plugins['Comments_on_Albums'])) $loaded['category'] = true;
8if (isset($pwg_loaded_plugins['GuestBook'])) $loaded['guestbook'] = true;
9
10// $conf['cryptographp'] = unserialize($conf['cryptographp']);
11load_language('plugin.lang', CRYPTO_PATH);
12
13if ( isset($_POST['submit']))
14{
15  $conf['cryptographp'] = array(
16    'activate_on'     => array(
17          'picture'     => isset($_POST['activate_on']['picture']),
18          'category'    => isset($_POST['activate_on']['category']) || !isset($loaded['category']),
19          'register'    => isset($_POST['activate_on']['register']),
20          'contactform' => isset($_POST['activate_on']['contactform']) || !isset($loaded['contactform']),
21          'guestbook'   => isset($_POST['activate_on']['guestbook']) || !isset($loaded['guestbook']),
22          ),
23    'comments_action' => $_POST['comments_action'],
24    'theme'           => $_POST['theme'],
25    'captcha_type'    => $_POST['captcha_type'],
26    'case_sensitive'  => 'false', //not used, problem with some fonts
27    'width'           => (int)$_POST['width'], 
28    'height'          => (int)$_POST['height'],
29    'perturbation'    => (float)$_POST['perturbation'],
30    'image_bg_color'  => $_POST['image_bg_color'],
31    'code_length'     => (int)$_POST['code_length'],
32    'text_color'      => $_POST['text_color'],
33    'num_lines'       => (float)$_POST['num_lines'],
34    'line_color'      => $_POST['line_color'],
35    'noise_level'     => (float)$_POST['noise_level'],
36    'noise_color'     => $_POST['noise_color'],
37    'ttf_file'        => $_POST['ttf_file'],
38    );
39 
40  conf_update_param('cryptographp', serialize($conf['cryptographp']));
41  array_push($page['infos'], l10n('Information data registered in database'));
42}
43
44$presets = array(
45  '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'),
46  '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'),
47  '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'),
48  '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'),
49  );
50 
51function list_fonts($dir)
52{
53  $dir = rtrim($dir, '/');
54  $dh = opendir($dir);
55  $fonts = array();
56 
57  while (($file = readdir($dh)) !== false )
58  {
59    if ($file !== '.' && $file !== '..') $fonts[] = str_replace('.ttf', null, $file);
60  }
61 
62  closedir($dh);
63  return $fonts;
64}
65
66function presets_to_js($presets)
67{
68  $out = null;
69 
70  foreach ($presets as $name => $param)
71  {
72    $out.= '
73function apply_'.$name.'() {
74  $("input[name=perturbation]").val("'.$param['perturbation'].'");
75  $("input[name=image_bg_color]").val("'.$param['image_bg_color'].'");
76  $("input[name=text_color]").val("'.$param['text_color'].'");
77  $("input[name=num_lines]").val("'.$param['num_lines'].'");
78  $("input[name=line_color]").val("'.$param['line_color'].'");
79  $("input[name=noise_level]").val("'.$param['noise_level'].'");
80  $("input[name=noise_color]").val("'.$param['noise_color'].'");
81  $("input[name=ttf_file]").val(["'.$param['ttf_file'].'"]);
82}';
83  }
84   
85  return $out;
86}
87
88$template->assign(array(
89  'crypto' => $conf['cryptographp'],
90  'loaded' => $loaded,
91  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
92  'presets' => array_keys($presets),
93  'PRESETS_FUNC' => presets_to_js($presets),
94  'CRYPTO_PATH' => CRYPTO_PATH,
95  ));
96
97$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
98$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
99
100?>
Note: See TracBrowser for help on using the repository browser.