1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<?php /** * This plugin will edit the tokens in the %DATA_FOLDER% zenphoto.cfg file * * * @author Stephen Billard (sbillard) * @package plugins * @subpackage admin */ $plugin_is_filter = 97 | ADMIN_PLUGIN; $plugin_description = gettext('Utility to alter the rewrite token substitutions array in the configuration file.'); $plugin_author = "Stephen Billard (sbillard)";
$option_interface = 'rewriteTokens';
require_once(SERVERPATH . '/' . ZENFOLDER . '/functions-config.php');
class rewriteTokens {
private $zp_cfg_a; private $zp_cfg_b; private $conf_vars;
function __construct() { global $_configMutex; $_configMutex->lock(); $zp_cfg = file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE); $i = strpos($zp_cfg, "\$conf['special_pages']"); $j = strpos($zp_cfg, '//', $i); $this->zp_cfg_a = substr($zp_cfg, 0, $i); $this->zp_cfg_b = substr($zp_cfg, $j); eval(substr($zp_cfg, $i, $j - $i)); $this->conf_vars = $conf; if (OFFSET_PATH == 2) { $old = array_keys($conf['special_pages']); $zp_cfg = file_get_contents(SERVERPATH . '/' . ZENFOLDER . '/zenphoto_cfg.txt'); $i = strpos($zp_cfg, "\$conf['special_pages']"); $j = strpos($zp_cfg, '//', $i); eval(substr($zp_cfg, $i, $j - $i)); $new = array_keys($conf['special_pages']); if ($old != $new) { //Things have changed, need to reset to defaults; setOption('rewriteTokens_restore', 1); $this->handleOptionSave(NULL, NULL); setupLog(gettext('rewriteTokens restored to default'), true); } } else { enableExtension('rewriteTokens', 97 | ADMIN_PLUGIN); // plugin must be enabled for saving options } }
function __destruct() { global $_configMutex; $_configMutex->unlock(); }
function getOptionsSupported() { $options = array(); $c = 0; foreach ($this->conf_vars['special_pages'] as $page => $element) { if ($define = $element['define']) { $define = "'" . $define . "'"; $desc = sprintf(gettext('Link for <em>%s</em> rule.'), $page); } else { $define = 'false'; $desc = sprintf(gettext('Link for <em>%s</em> script page.'), $page); } $options[$page] = array('key' => 'rewriteTokens_' . $page, 'type' => OPTION_TYPE_CUSTOM, 'order' => ++$c, 'desc' => $desc); } $options[gettext('Reset')] = array('key' => 'rewriteTokens_restore', 'type' => OPTION_TYPE_CHECKBOX, 'order' => ++$c, 'desc' => gettext('Restore defaults.')); return $options; }
function handleOption($option, $currentValue) { $element = $this->conf_vars['special_pages'][str_replace('rewriteTokens_', '', $option)]['rewrite']; ?> <input type="textbox" name="<?php echo $option; ?>" value="<?php echo $element; ?>" > <?php }
function handleOptionSave($theme, $album) { if (getOption('rewriteTokens_restore')) { $updated = false; purgeOption('rewriteTokens_restore'); $template = file_get_contents(SERVERPATH . '/' . ZENFOLDER . '/zenphoto_cfg.txt'); $i = strpos($template, "\$conf['special_pages']"); $j = strpos($template, '//', $i); $newtext = substr($template, $i, $j - $i); eval($newtext); $this->conf_vars = $conf; } else { foreach ($this->conf_vars['special_pages'] as $page => $element) { $this->conf_vars['special_pages'][$page]['rewrite'] = $_POST['rewriteTokens_' . $page]; } } $newtext = "\$conf['special_pages'] = array("; foreach ($this->conf_vars['special_pages'] as $page => $element) { if ($define = $element['define']) { $define = "'" . $define . "'"; $desc = sprintf(gettext('Link for <em>%s</em> rule.'), $page); } else { $define = 'false'; $desc = sprintf(gettext('Link for <em>%s</em> script page.'), $page); } if (array_key_exists('rule', $element)) { $rule = ", 'rule'=>'{$element['rule']}'"; } else { $rule = ''; } $newtext .= $token = "\n '$page'=> array('define'=>$define, 'rewrite'=>'{$element['rewrite']}'$rule),"; } $newtext = substr($newtext, 0, -1) . "\n );\n"; $zp_cfg = $this->zp_cfg_a . $newtext . $this->zp_cfg_b; storeConfig($zp_cfg); $options['note'] = array( 'key' => 'rewriteTokens_note', 'type' => OPTION_TYPE_NOTE, 'order' => 0, 'desc' => sprintf(gettext('<p class="messagebox"><em>%1$s</em> updated.</p>'), CONFIGFILE) ); }
} ?>
|