[10837] | 1 | <?php |
---|
[26041] | 2 | defined('CRYPTO_ID') or die('Hacking attempt!'); |
---|
[10837] | 3 | |
---|
[15996] | 4 | global $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']), |
---|
[26041] | 9 | 'easycaptcha' => isset($pwg_loaded_plugins['EasyCaptcha']), |
---|
[19428] | 10 | ); |
---|
[15996] | 11 | |
---|
[26041] | 12 | if ($loaded['easycaptcha']) |
---|
| 13 | { |
---|
| 14 | $page['warnings'][] = l10n('We detected that EasyCaptcha plugin is available on your gallery. Both plugins can be used at the same time, but you should not under any circumstances activate both of them on the same page.'); |
---|
| 15 | } |
---|
[19428] | 16 | |
---|
[10837] | 17 | if ( isset($_POST['submit'])) |
---|
[26041] | 18 | { |
---|
| 19 | if (!isset($_POST['activate_on'])) $_POST['activate_on'] = array(); |
---|
| 20 | |
---|
[12617] | 21 | $conf['cryptographp'] = array( |
---|
[26072] | 22 | 'activate_on' => array( |
---|
[26041] | 23 | 'picture' => in_array('picture', $_POST['activate_on']), |
---|
| 24 | 'category' => in_array('category', $_POST['activate_on']) || !$loaded['category'], |
---|
| 25 | 'register' => in_array('register', $_POST['activate_on']), |
---|
| 26 | 'contactform' => in_array('contactform', $_POST['activate_on']) || !$loaded['contactform'], |
---|
| 27 | 'guestbook' => in_array('guestbook', $_POST['activate_on']) || !$loaded['guestbook'], |
---|
| 28 | ), |
---|
[12617] | 29 | 'comments_action' => $_POST['comments_action'], |
---|
| 30 | 'theme' => $_POST['theme'], |
---|
| 31 | 'captcha_type' => $_POST['captcha_type'], |
---|
[14527] | 32 | 'case_sensitive' => 'false', //not used, problem with some fonts |
---|
[12617] | 33 | 'width' => (int)$_POST['width'], |
---|
| 34 | 'height' => (int)$_POST['height'], |
---|
| 35 | 'perturbation' => (float)$_POST['perturbation'], |
---|
[26554] | 36 | 'background' => $_POST['background'], |
---|
| 37 | 'bg_color' => $_POST['bg_color'], |
---|
| 38 | 'bg_image' => $_POST['bg_image'], |
---|
[12617] | 39 | 'code_length' => (int)$_POST['code_length'], |
---|
| 40 | 'text_color' => $_POST['text_color'], |
---|
| 41 | 'num_lines' => (float)$_POST['num_lines'], |
---|
| 42 | 'line_color' => $_POST['line_color'], |
---|
| 43 | 'noise_level' => (float)$_POST['noise_level'], |
---|
| 44 | 'noise_color' => $_POST['noise_color'], |
---|
| 45 | 'ttf_file' => $_POST['ttf_file'], |
---|
[19428] | 46 | 'button_color' => $_POST['button_color'], |
---|
[11316] | 47 | ); |
---|
[12617] | 48 | |
---|
| 49 | conf_update_param('cryptographp', serialize($conf['cryptographp'])); |
---|
[26041] | 50 | $page['infos'][] = l10n('Information data registered in database'); |
---|
[10837] | 51 | } |
---|
| 52 | |
---|
[12617] | 53 | $presets = array( |
---|
[26554] | 54 | 'bluenoise' => array('perturbation'=>0.25, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2, 'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'), |
---|
| 55 | 'gray' => array('perturbation'=>1, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'), |
---|
| 56 | 'xcolor' => array('perturbation'=>0.5, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2, 'noise_color'=>'ffffff', 'ttf_file'=>'Dread'), |
---|
| 57 | 'pencil' => array('perturbation'=>0.8, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'), |
---|
| 58 | 'ransom' => array('perturbation'=>0, 'background'=>'image', 'bg_image'=>'bg1.jpg', 'bg_color'=>'ffffff', 'text_color'=>'4a003a', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'ransom'), |
---|
[12617] | 59 | ); |
---|
[26554] | 60 | |
---|
| 61 | |
---|
| 62 | $template->assign(array( |
---|
| 63 | 'crypto' => $conf['cryptographp'], |
---|
| 64 | 'loaded' => $loaded, |
---|
| 65 | 'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), |
---|
| 66 | 'backgrounds' => list_backgrounds(CRYPTO_PATH.'securimage/backgrounds'), |
---|
| 67 | 'PRESETS' => $presets, |
---|
| 68 | 'CRYPTO_PATH' => CRYPTO_PATH, |
---|
| 69 | )); |
---|
| 70 | |
---|
| 71 | $template->set_filename('plugin_admin_content', realpath(CRYPTO_PATH . 'template/admin.tpl')); |
---|
| 72 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
[12617] | 76 | function list_fonts($dir) |
---|
| 77 | { |
---|
| 78 | $dir = rtrim($dir, '/'); |
---|
| 79 | $dh = opendir($dir); |
---|
| 80 | $fonts = array(); |
---|
| 81 | |
---|
| 82 | while (($file = readdir($dh)) !== false ) |
---|
| 83 | { |
---|
[22725] | 84 | if ($file !== '.' && $file !== '..' && get_extension($file)=='ttf') |
---|
[26554] | 85 | { |
---|
| 86 | $fonts[get_filename_wo_extension($file)] = $dir . '/' . $file; |
---|
| 87 | } |
---|
[12617] | 88 | } |
---|
| 89 | |
---|
| 90 | closedir($dh); |
---|
| 91 | return $fonts; |
---|
| 92 | } |
---|
[10837] | 93 | |
---|
[26554] | 94 | function list_backgrounds($dir) |
---|
| 95 | { |
---|
| 96 | $dir = rtrim($dir, '/'); |
---|
| 97 | $dh = opendir($dir); |
---|
| 98 | $backgrounds = array(); |
---|
| 99 | |
---|
| 100 | while (($file = readdir($dh)) !== false ) |
---|
| 101 | { |
---|
| 102 | if ($file !== '.' && $file !== '..') |
---|
| 103 | { |
---|
| 104 | $ext = get_extension($file); |
---|
| 105 | if ($ext=='jpg' || $ext=='png' || $ext=='jpeg' || $ext=='gif') |
---|
| 106 | { |
---|
| 107 | $backgrounds[$file] = $dir . '/' . $file; |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | closedir($dh); |
---|
| 113 | return $backgrounds; |
---|
| 114 | } |
---|