source: extensions/CryptograPHP/maintain.inc.php @ 26413

Last change on this file since 26413 was 26072, checked in by mistic100, 10 years ago

try to simplify integration of captchas

File size: 2.3 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class CryptograPHP_maintain extends PluginMaintain
5{
6  private $installed = false;
7
8  function install($plugin_version, &$errors=array())
9  {
10    global $conf;
11   
12    if (isset($conf['cryptograph_theme']))
13    {
14      conf_delete_param('cryptograph_theme');
15    }
16   
17    if (empty($conf['cryptographp']))
18    {
19      $default_config = array(
20        'activate_on'     => array(
21              'picture'     => true,
22              'category'    => true,
23              'register'    => true,
24              'contactform' => true,
25              'guestbook'   => true,
26              ),
27        'comments_action' => 'reject',
28        'theme'           => 'gray',
29        'captcha_type'    => 'string',
30        'case_sensitive'  => 'false',
31        'code_length'     => 6,
32        'width'           => 180, 
33        'height'          => 70,
34        'perturbation'    => 1, 
35        'image_bg_color'  => 'ffffff', 
36        'text_color'      => '8a8a8a', 
37        'num_lines'       => 2, 
38        'line_color'      => '8a8a8a', 
39        'noise_level'     => 0.1, 
40        'noise_color'     => '8a8a8a', 
41        'ttf_file'        => 'TopSecret',
42        'button_color'    => 'dark',
43        );
44   
45      $conf['cryptographp'] = serialize($default_config);
46      conf_update_param('cryptographp', $conf['cryptographp']);
47    }
48    else
49    {
50      $old_conf = is_string($conf['cryptographp']) ? unserialize($conf['cryptographp']) : $conf['cryptographp'];
51     
52      if (!isset($old_conf['activate_on']))
53      {
54        $old_conf['activate_on'] = array(
55          'picture'     => $old_conf['comments_action'] != 'inactive',
56          'category'    => $old_conf['comments_action'] != 'inactive',
57          'register'    => true,
58          'contactform' => true,
59          'guestbook'   => true,
60          );
61      }
62      if (!isset($old_conf['button_color']))
63      {
64        $old_conf['button_color'] = 'dark';
65      }
66     
67      $conf['cryptographp'] = serialize($old_conf);
68      conf_update_param('cryptographp', $conf['cryptographp']);
69    }
70
71    $this->installed = true;
72  }
73
74  function activate($plugin_version, &$errors=array())
75  {
76    if (!$this->installed)
77    {
78      $this->install($plugin_version, $errors);
79    }
80  }
81
82  function deactivate()
83  {
84  }
85
86  function uninstall()
87  {
88    conf_delete_param('cryptographp');
89  }
90}
Note: See TracBrowser for help on using the repository browser.