source: extensions/EasyCaptcha/admin.php @ 24233

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

error when open_basedir restriction in effect

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