[10837] | 1 | <?php |
---|
[20189] | 2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[12617] | 3 | |
---|
[26041] | 4 | class CryptograPHP_maintain extends PluginMaintain |
---|
[10837] | 5 | { |
---|
[26041] | 6 | private $installed = false; |
---|
[10837] | 7 | |
---|
[26041] | 8 | function install($plugin_version, &$errors=array()) |
---|
[11316] | 9 | { |
---|
[26072] | 10 | global $conf; |
---|
| 11 | |
---|
[26041] | 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, |
---|
[26554] | 34 | 'perturbation' => 1, |
---|
| 35 | 'background' => 'color', |
---|
| 36 | 'bg_color' => 'ffffff', |
---|
| 37 | 'bg_image' => '', |
---|
[26041] | 38 | 'text_color' => '8a8a8a', |
---|
| 39 | 'num_lines' => 2, |
---|
| 40 | 'line_color' => '8a8a8a', |
---|
| 41 | 'noise_level' => 0.1, |
---|
| 42 | 'noise_color' => '8a8a8a', |
---|
| 43 | 'ttf_file' => 'TopSecret', |
---|
| 44 | 'button_color' => 'dark', |
---|
| 45 | ); |
---|
| 46 | |
---|
| 47 | $conf['cryptographp'] = serialize($default_config); |
---|
| 48 | conf_update_param('cryptographp', $conf['cryptographp']); |
---|
| 49 | } |
---|
| 50 | else |
---|
| 51 | { |
---|
| 52 | $old_conf = is_string($conf['cryptographp']) ? unserialize($conf['cryptographp']) : $conf['cryptographp']; |
---|
| 53 | |
---|
| 54 | if (!isset($old_conf['activate_on'])) |
---|
| 55 | { |
---|
| 56 | $old_conf['activate_on'] = array( |
---|
| 57 | 'picture' => $old_conf['comments_action'] != 'inactive', |
---|
| 58 | 'category' => $old_conf['comments_action'] != 'inactive', |
---|
| 59 | 'register' => true, |
---|
| 60 | 'contactform' => true, |
---|
| 61 | 'guestbook' => true, |
---|
| 62 | ); |
---|
| 63 | } |
---|
| 64 | if (!isset($old_conf['button_color'])) |
---|
| 65 | { |
---|
| 66 | $old_conf['button_color'] = 'dark'; |
---|
| 67 | } |
---|
[26554] | 68 | if (!isset($old_conf['background'])) |
---|
| 69 | { |
---|
| 70 | $old_conf['background'] = 'color'; |
---|
| 71 | $old_conf['bg_color'] = $old_conf['image_bg_color']; |
---|
| 72 | $old_conf['bg_image'] = ''; |
---|
| 73 | unset($old_conf['image_bg_color']); |
---|
| 74 | } |
---|
[26041] | 75 | |
---|
| 76 | $conf['cryptographp'] = serialize($old_conf); |
---|
| 77 | conf_update_param('cryptographp', $conf['cryptographp']); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | $this->installed = true; |
---|
[11316] | 81 | } |
---|
[14527] | 82 | |
---|
[26041] | 83 | function activate($plugin_version, &$errors=array()) |
---|
| 84 | { |
---|
| 85 | if (!$this->installed) |
---|
| 86 | { |
---|
| 87 | $this->install($plugin_version, $errors); |
---|
| 88 | } |
---|
| 89 | } |
---|
[10837] | 90 | |
---|
[26041] | 91 | function deactivate() |
---|
| 92 | { |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function uninstall() |
---|
| 96 | { |
---|
| 97 | conf_delete_param('cryptographp'); |
---|
| 98 | } |
---|
| 99 | } |
---|