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

Last change on this file since 28566 was 28344, checked in by mistic100, 10 years ago

add 'guest_only' option

File size: 2.8 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        'guest_only'      => true,
29        'theme'           => 'gray',
30        'captcha_type'    => 'string',
31        'case_sensitive'  => 'false',
32        'code_length'     => 6,
33        'width'           => 180, 
34        'height'          => 70,
35        'perturbation'    => 1,
36        'background'      => 'color',
37        'bg_color'        => 'ffffff', 
38        'bg_image'        => '', 
39        'text_color'      => '8a8a8a', 
40        'num_lines'       => 2, 
41        'line_color'      => '8a8a8a', 
42        'noise_level'     => 0.1, 
43        'noise_color'     => '8a8a8a', 
44        'ttf_file'        => 'TopSecret',
45        'button_color'    => 'dark',
46        );
47   
48      $conf['cryptographp'] = serialize($default_config);
49      conf_update_param('cryptographp', $conf['cryptographp']);
50    }
51    else
52    {
53      $old_conf = is_string($conf['cryptographp']) ? unserialize($conf['cryptographp']) : $conf['cryptographp'];
54     
55      if (!isset($old_conf['activate_on']))
56      {
57        $old_conf['activate_on'] = array(
58          'picture'     => $old_conf['comments_action'] != 'inactive',
59          'category'    => $old_conf['comments_action'] != 'inactive',
60          'register'    => true,
61          'contactform' => true,
62          'guestbook'   => true,
63          );
64      }
65      if (!isset($old_conf['button_color']))
66      {
67        $old_conf['button_color'] = 'dark';
68      }
69      if (!isset($old_conf['background']))
70      {
71        $old_conf['background'] = 'color';
72        $old_conf['bg_color'] = $old_conf['image_bg_color'];
73        $old_conf['bg_image'] = '';
74        unset($old_conf['image_bg_color']);
75      }
76      if (!isset($old_conf['guest_only']))
77      {
78        $old_conf['guest_only'] = true;
79      }
80     
81      $conf['cryptographp'] = serialize($old_conf);
82      conf_update_param('cryptographp', $conf['cryptographp']);
83    }
84
85    $this->installed = true;
86  }
87
88  function activate($plugin_version, &$errors=array())
89  {
90    if (!$this->installed)
91    {
92      $this->install($plugin_version, $errors);
93    }
94  }
95
96  function deactivate()
97  {
98  }
99
100  function uninstall()
101  {
102    conf_delete_param('cryptographp');
103  }
104}
Note: See TracBrowser for help on using the repository browser.