source: extensions/CryptograPHP/maintain.class.php @ 30210

Last change on this file since 30210 was 28838, checked in by mistic100, 10 years ago

use new maintain class

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