[10837] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[15996] | 4 | global $pwg_loaded_plugins; |
---|
| 5 | $loaded = array(); |
---|
| 6 | if (isset($pwg_loaded_plugins['ContactForm'])) $loaded['contactform'] = true; |
---|
| 7 | if (isset($pwg_loaded_plugins['Comments_on_Albums'])) $loaded['category'] = true; |
---|
| 8 | if (isset($pwg_loaded_plugins['GuestBook'])) $loaded['guestbook'] = true; |
---|
| 9 | |
---|
[12619] | 10 | // $conf['cryptographp'] = unserialize($conf['cryptographp']); |
---|
[10837] | 11 | load_language('plugin.lang', CRYPTO_PATH); |
---|
| 12 | |
---|
| 13 | if ( isset($_POST['submit'])) |
---|
| 14 | { |
---|
[12617] | 15 | $conf['cryptographp'] = array( |
---|
[15996] | 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 | ), |
---|
[12617] | 23 | 'comments_action' => $_POST['comments_action'], |
---|
| 24 | 'theme' => $_POST['theme'], |
---|
| 25 | 'captcha_type' => $_POST['captcha_type'], |
---|
[14527] | 26 | 'case_sensitive' => 'false', //not used, problem with some fonts |
---|
[12617] | 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'], |
---|
[11316] | 38 | ); |
---|
[12617] | 39 | |
---|
| 40 | conf_update_param('cryptographp', serialize($conf['cryptographp'])); |
---|
[10837] | 41 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
| 42 | } |
---|
| 43 | |
---|
[12617] | 44 | $presets = array( |
---|
[14527] | 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'), |
---|
[12617] | 49 | ); |
---|
| 50 | |
---|
| 51 | function 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 | } |
---|
[10837] | 65 | |
---|
[12617] | 66 | function presets_to_js($presets) |
---|
| 67 | { |
---|
| 68 | $out = null; |
---|
| 69 | |
---|
| 70 | foreach ($presets as $name => $param) |
---|
| 71 | { |
---|
| 72 | $out.= ' |
---|
| 73 | function 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 | |
---|
[10837] | 88 | $template->assign(array( |
---|
[12617] | 89 | 'crypto' => $conf['cryptographp'], |
---|
[15996] | 90 | 'loaded' => $loaded, |
---|
[12617] | 91 | 'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), |
---|
| 92 | 'presets' => array_keys($presets), |
---|
| 93 | 'PRESETS_FUNC' => presets_to_js($presets), |
---|
[10837] | 94 | 'CRYPTO_PATH' => CRYPTO_PATH, |
---|
[12617] | 95 | )); |
---|
[10837] | 96 | |
---|
[15996] | 97 | $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl'); |
---|
[11316] | 98 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
[10837] | 99 | |
---|
| 100 | ?> |
---|