[24215] | 1 | <?php |
---|
| 2 | defined('EASYCAPTCHA_ID') or die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $pwg_loaded_plugins; |
---|
| 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 | 'cryptocaptcha' => isset($pwg_loaded_plugins['CryptograPHP']), |
---|
| 10 | ); |
---|
| 11 | |
---|
| 12 | if ($loaded['cryptocaptcha']) |
---|
| 13 | { |
---|
[24234] | 14 | $page['warnings'][] = l10n('We detected that Crypto Captcha 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.'); |
---|
[24215] | 15 | } |
---|
| 16 | |
---|
| 17 | if (isset($_POST['submit'])) |
---|
| 18 | { |
---|
[24226] | 19 | if (!isset($_POST['activate_on'])) $_POST['activate_on'] = array(); |
---|
| 20 | |
---|
[24215] | 21 | $conf['EasyCaptcha'] = array( |
---|
[26025] | 22 | 'activate_on' => array( |
---|
[24215] | 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 | ), |
---|
| 29 | 'comments_action' => $_POST['comments_action'], |
---|
[28345] | 30 | 'guest_only' => isset($_POST['guest_only']), |
---|
[24215] | 31 | 'challenge' => $_POST['challenge'], |
---|
| 32 | 'drag' => array( |
---|
| 33 | 'theme' => $_POST['drag']['theme'], |
---|
| 34 | 'size' => (int)$_POST['drag']['size'], |
---|
| 35 | 'nb' => (int)$_POST['drag']['nb'], |
---|
| 36 | 'bg1' => check_color($_POST['drag']['bg1']), |
---|
| 37 | 'bg2' => check_color($_POST['drag']['bg2']), |
---|
| 38 | 'obj' => check_color($_POST['drag']['obj']), |
---|
| 39 | 'sel' => check_color($_POST['drag']['sel']), |
---|
| 40 | 'bd1' => check_color($_POST['drag']['bd1']), |
---|
| 41 | 'bd2' => check_color($_POST['drag']['bd2']), |
---|
| 42 | 'txt' => check_color($_POST['drag']['txt']), |
---|
| 43 | ), |
---|
| 44 | 'tictac' => array( |
---|
| 45 | 'size' => (int)$_POST['tictac']['size'], |
---|
| 46 | 'bg1' => check_color($_POST['tictac']['bg1']), |
---|
| 47 | 'bg2' => check_color($_POST['tictac']['bg2']), |
---|
| 48 | 'bd' => check_color($_POST['tictac']['bd']), |
---|
| 49 | 'obj' => check_color($_POST['tictac']['obj']), |
---|
| 50 | 'sel' => check_color($_POST['tictac']['sel']), |
---|
| 51 | ), |
---|
[26025] | 52 | 'lastmod' => time(), |
---|
[24215] | 53 | ); |
---|
| 54 | |
---|
[28840] | 55 | conf_update_param('EasyCaptcha', $conf['EasyCaptcha']); |
---|
[26025] | 56 | $page['infos'][] = l10n('Information data registered in database'); |
---|
[24215] | 57 | } |
---|
| 58 | |
---|
| 59 | function list_themes($dir) |
---|
| 60 | { |
---|
| 61 | $dir = rtrim($dir, '/'); |
---|
| 62 | $dh = opendir($dir); |
---|
| 63 | $themes = array(); |
---|
| 64 | |
---|
| 65 | while (($item = readdir($dh)) !== false ) |
---|
| 66 | { |
---|
[26025] | 67 | if ($item!=='.' && $item!=='..' && |
---|
| 68 | is_dir($dir.'/'.$item) && file_exists($dir.'/'.$item.'/conf.inc.php') |
---|
| 69 | ) |
---|
[24215] | 70 | { |
---|
| 71 | $drag_images = include($dir.'/'.$item.'/conf.inc.php'); |
---|
| 72 | $themes[$item] = array( |
---|
| 73 | 'image' => key($drag_images), |
---|
| 74 | 'count' => count($drag_images), |
---|
| 75 | ); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | closedir($dh); |
---|
| 80 | return $themes; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | $template->assign(array( |
---|
| 84 | 'easycaptcha' => $conf['EasyCaptcha'], |
---|
| 85 | 'loaded' => $loaded, |
---|
[26025] | 86 | 'THEMES' => list_themes(EASYCAPTCHA_PATH . 'drag'), |
---|
[24215] | 87 | 'EASYCAPTCHA_PATH' => EASYCAPTCHA_PATH, |
---|
[26025] | 88 | 'EASYCAPTCHA_ABS_PATH' => realpath(EASYCAPTCHA_PATH) . '/', |
---|
| 89 | 'DRAG_CSS' => file_get_contents(EASYCAPTCHA_PATH . 'template/drag.css'), |
---|
[24215] | 90 | )); |
---|
| 91 | |
---|
[26025] | 92 | $template->set_filename('plugin_admin_content', realpath(EASYCAPTCHA_PATH . 'template/admin.tpl')); |
---|
[24215] | 93 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | function check_color($hex) |
---|
| 97 | { |
---|
| 98 | global $page; |
---|
| 99 | |
---|
| 100 | $hex = ltrim($hex, '#'); |
---|
| 101 | |
---|
| 102 | if (strlen($hex) == 3) |
---|
| 103 | { |
---|
| 104 | $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; |
---|
| 105 | } |
---|
[26831] | 106 | else if (strlen($hex) != 6 || !ctype_xdigit($hex)) |
---|
[24215] | 107 | { |
---|
[26025] | 108 | $page['errors'][] = l10n('Invalid color code <i>%s</i>', '#'.$hex); |
---|
[24215] | 109 | $hex = '000000'; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | return '#'.$hex; |
---|
| 113 | } |
---|