• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão6bace81b1de67c363c9c7fa68b5238145d962cc6 (tree)
Hora2022-01-24 02:04:32
Autorhai-fun <haifun129@gmai...>
Commiterhai-fun

Mensagem de Log

PHP8

Mudança Sumário

Diff

--- a/regexp.inc.php
+++ b/regexp.inc.php
@@ -8,473 +8,513 @@
88 * @version $Id: regexp.inc.php,v 1.4 2008-07-20 07:23:17Z sonots $
99 * @package plugin
1010 */
11+ // v1.41 PHP8.0対応 2021-12-15 byはいふん
1112
1213 class PluginRegexp
1314 {
14- function PluginRegexp()
15- {
16- // modify here for default values
17- static $conf = array(
18- 'ignore_freeze' => TRUE,
19- 'adminonly' => TRUE,
20- );
21- static $default_options = array(
22- 'pcmd' => '',
23- 'pass' => '',
24- 'filter' => '',
25- 'except' => '',
26- 'page' => '',
27- 'search' => '',
28- 'replace' => '',
29- 'regexp' => TRUE,
30- 'msearch' => '',
31- 'mreplace' => '',
32- 'notimestamp' => TRUE,
33- );
34- $this->conf = & $conf;
35- $this->default_options = & $default_options;
15+ function __construct()
16+ {
17+ // modify here for default values
18+ static $conf = array(
19+ 'ignore_freeze' => TRUE,
20+ 'adminonly' => TRUE,
21+ );
22+ static $default_options = array(
23+ 'pcmd' => '',
24+ 'pass' => '',
25+ 'filter' => '',
26+ 'except' => '',
27+ 'page' => '',
28+ 'search' => '',
29+ 'replace' => '',
30+ 'regexp' => TRUE,
31+ 'msearch' => '',
32+ 'mreplace' => '',
33+ 'notimestamp' => TRUE,
34+ );
35+ $this->conf = & $conf;
36+ $this->default_options = & $default_options;
3637
37- // init
38- $this->options = $this->default_options;
39- $this->view = new PluginRegexpView($this);
40- }
38+ // init
39+ $this->options = $this->default_options;
40+ $this->view = new PluginRegexpView($this);
41+ }
4142
42- // static
43- var $conf;
44- var $default_values;
45- // var
46- var $error = '';
47- var $plugin = 'regexp';
48- var $options = array();
49- var $view;
50- var $preg_replace;
51- var $str_replace;
43+ function PluginRegexp() {
44+ $this->__construct();
45+ }
5246
53- function action()
54- {
55- set_time_limit(0);
56- global $vars;
57- foreach ($this->options as $key => $val) {
58- $this->options[$key] = isset($vars[$key]) ? $vars[$key] : '';
59- }
60- foreach ($this->options as $key => $val) {
61- ${$key} = $val;
62- }
63- if ($pcmd == '') {
64- $body = $this->view->showform();
65- } elseif ($search == '' && $msearch == '') {
66- $body = $this->view->showform('No search.');
67- } elseif (! $this->view->login()) { // auth::check_role('role_adm_contents')
68- $body = $this->view->showform('The password is wrong.');
69- } elseif ($pcmd == 'preview') {
70- $body = $this->do_preview();
71- } elseif ($pcmd == 'replace') {
72- $pages = $this->do_replace_all();
73- $body = $this->view->result($pages);
74- }
75- return array('msg'=>$this->plugin, 'body'=>$body);
76- }
47+ // static
48+ var $conf;
49+ var $default_values;
50+ // var
51+ var $error = '';
52+ var $plugin = 'regexp';
53+ var $options = array();
54+ var $view;
55+ var $preg_replace;
56+ var $str_replace;
7757
78- function do_preview()
79- {
80- foreach ($this->options as $key => $val) {
81- ${$key} = $val;
82- }
83- $diff = '';
84- $pages = $this->get_pages($filter, $except, $page);
85- foreach ($pages as $apage) {
86- $replaced = $this->replace($apage, $search, $replace, $msearch, $mreplace, $regexp);
87- if (is_null($replaced)) continue;
88- $source = implode("", get_source($apage));
89- $diff = do_diff($source, $replaced);
90- break;
91- }
92- $body = $this->view->preview($apage, $diff, $pages);
93- return $body;
94- }
58+ function action()
59+ {
60+ set_time_limit(0);
61+ global $vars;
62+ foreach ($this->options as $key => $val) {
63+ $this->options[$key] = isset($vars[$key]) ? $vars[$key] : '';
64+ }
65+ foreach ($this->options as $key => $val) {
66+ ${$key} = $val;
67+ }
68+ if ($pcmd == '') {
69+ $body = $this->view->showform();
70+ } elseif ($search == '' && $msearch == '') {
71+ $body = $this->view->showform('No search.');
72+ } elseif (! $this->view->login()) { // auth::check_role('role_adm_contents')
73+ $body = $this->view->showform('The password is wrong.');
74+ } elseif ($pcmd == 'preview') {
75+ $body = $this->do_preview();
76+ } elseif ($pcmd == 'replace') {
77+ $pages = $this->do_replace_all();
78+ $body = $this->view->result($pages);
79+ }
80+ return array('msg'=>$this->plugin, 'body'=>$body);
81+ }
9582
83+ function do_preview()
84+ {
85+ foreach ($this->options as $key => $val) {
86+ ${$key} = $val;
87+ }
88+ $diff = '';
89+ $pages = $this->get_pages($filter, $except, $page);
90+ foreach ($pages as $apage) {
91+ $replaced = $this->replace($apage, $search, $replace, $msearch, $mreplace, $regexp);
92+ if (is_null($replaced)) continue;
93+ $source = implode("", get_source($apage));
94+ $diff = do_diff($source, $replaced);
95+ break;
96+ }
97+ $body = $this->view->preview($apage, $diff, $pages);
98+ return $body;
99+ }
96100
97- function do_replace_all()
98- {
99- foreach ($this->options as $key => $val) {
100- ${$key} = $val;
101- }
102- $pages = $this->get_pages($filter, $except, $page);
103- $replaced_pages = array();
104- foreach ($pages as $apage) {
105- $replaced = $this->replace($apage, $search, $replace, $msearch, $mreplace, $regexp);
106- if (is_null($replaced)) continue;
107- $GLOBALS['cycle'] = 0;
108- page_write($apage, $replaced, $notimestamp);
109- $replaced_pages[] = $apage;
110- }
111- return $replaced_pages;
112- }
113101
114- /**
115- * Replace contents of a page
116- *
117- * @param string $page
118- * @param string $search
119- * @param string $replace
120- * @param string $msearch multiline search
121- * @param string $mreplace
122- * @param boolean $regexp
123- * @param string|null replaced contents. null if no replace occurred
124- */
125- function replace($page, $search, $replace, $msearch, $mreplace, $regexp = TRUE)
126- {
127- if (! $this->is_editable($page)) return null;
128- if ($regexp) {
129- // mb_preg_replace usually does not exist.
130- $replace_func = function_exists('mb_preg_replace') ? 'mb_preg_replace' : 'preg_replace';
131- if ($msearch != '') $msearch = '/' . str_replace('/', '\/', $msearch) . '/D';
132- // Memo: refer http://us.php.net/manual/ja/reference.pcre.pattern.modifiers.php for D.
133- if ($search != '') $search = '/' . str_replace('/', '\/', $search) . '/';
134- } else {
135- // mb_str_replace usually does not exist.
136- $replace_func = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
137- }
138- $lines = get_source($page);
139- $source = implode("", $lines);
140- if ($msearch != '') {
141- $msearch = str_replace("\r", "\n", str_replace("\r\n", "\n", $msearch));
142- $replace = call_user_func($replace_func, $msearch, $mreplace, $source);
143- } elseif ($search != '') {
144- $replace_lines = array();
145- foreach ($lines as $line) {
146- $line = rtrim($line, "\n");
147- $replace_lines[] = call_user_func($replace_func, $search, $replace, $line) . "\n";
148- }
149- $replace = implode("", $replace_lines);
150- }
151- if ($source == $replace) return null;
152- return $replace;
153- }
102+ function do_replace_all()
103+ {
104+ foreach ($this->options as $key => $val) {
105+ ${$key} = $val;
106+ }
107+ $pages = $this->get_pages($filter, $except, $page);
108+ $replaced_pages = array();
109+ foreach ($pages as $apage) {
110+ $replaced = $this->replace($apage, $search, $replace, $msearch, $mreplace, $regexp);
111+ if (is_null($replaced)) continue;
112+ $GLOBALS['cycle'] = 0;
113+ page_write($apage, $replaced, $notimestamp);
114+ $replaced_pages[] = $apage;
115+ }
116+ return $replaced_pages;
117+ }
154118
155- /**
156- * Get filtered pages (not all existpages)
157- *
158- * @param string $filter regexp filter
159- * @param string $except regexp except filter
160- * @param string $onepage one exact page name
161- */
162- function get_pages($filter = '', $except = '', $onepage = '')
163- {
164- if (! empty($onepage)) {
165- return (array)$onepage;
166- }
167- if (method_exists('auth', 'get_existpages')) { // plus!
168- $pages = auth::get_existpages();
169- } else {
170- $pages = get_existpages();
171- }
172- if (! empty($filter)) {
173- $pregfilter = '/' . str_replace('/', '\/', $filter) . '/';
174- foreach($pages as $file => $page) {
175- if (! preg_match($pregfilter, $page)) {
176- unset($pages[$file]);
177- }
178- }
179- }
180- if (! empty($except)) {
181- $pregexcept = '/' . str_replace('/', '\/', $except) . '/';
182- foreach($pages as $file => $page) {
183- if (preg_match($pregexcept, $page)) {
184- unset($pages[$file]);
185- }
186- }
187- }
188- return $pages;
189- }
119+ /**
120+ * Replace contents of a page
121+ *
122+ * @param string $page
123+ * @param string $search
124+ * @param string $replace
125+ * @param string $msearch multiline search
126+ * @param string $mreplace
127+ * @param boolean $regexp
128+ * @param string|null replaced contents. null if no replace occurred
129+ */
130+ function replace($page, $search, $replace, $msearch, $mreplace, $regexp = TRUE)
131+ {
132+ if (! $this->is_editable($page)) return null;
133+ if ($regexp) {
134+ // mb_preg_replace usually does not exist.
135+ $replace_func = function_exists('mb_preg_replace') ? 'mb_preg_replace' : 'preg_replace';
136+ if ($msearch != '') $msearch = '/' . str_replace('/', '\/', $msearch) . '/D';
137+ // Memo: refer http://us.php.net/manual/ja/reference.pcre.pattern.modifiers.php for D.
138+ if ($search != '') $search = '/' . str_replace('/', '\/', $search) . '/';
139+ } else {
140+ // mb_str_replace usually does not exist.
141+ $replace_func = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
142+ }
143+ $lines = get_source($page);
144+ $source = implode("", $lines);
145+ if ($msearch != '') {
146+ $msearch = str_replace("\r", "\n", str_replace("\r\n", "\n", $msearch));
147+ $replace = call_user_func($replace_func, $msearch, $mreplace, $source);
148+ } elseif ($search != '') {
149+ $replace_lines = array();
150+ foreach ($lines as $line) {
151+ $line = rtrim($line, "\n");
152+ $replace_lines[] = call_user_func($replace_func, $search, $replace, $line) . "\n";
153+ }
154+ $replace = implode("", $replace_lines);
155+ }
156+ if ($source == $replace) return null;
157+ return $replace;
158+ }
190159
191- /**
192- * Check if the page is editable or not
193- *
194- * PukiWIki API Extension
195- *
196- * @param string $page
197- * @return boolean
198- */
199- function is_editable($page)
200- {
201- global $cantedit;
202- if ($this->conf['ignore_freeze']) {
203- $editable = ! in_array($page, $cantedit);
204- } else {
205- $editable = (! is_freeze($page) and ! in_array($page, $cantedit) );
206- }
207- return $editable;
208- }
160+ /**
161+ * Get filtered pages (not all existpages)
162+ *
163+ * @param string $filter regexp filter
164+ * @param string $except regexp except filter
165+ * @param string $onepage one exact page name
166+ */
167+ function get_pages($filter = '', $except = '', $onepage = '')
168+ {
169+ if (! empty($onepage)) {
170+ return (array)$onepage;
171+ }
172+ if (method_exists('auth', 'get_existpages')) { // plus!
173+ $pages = auth::get_existpages();
174+ } else {
175+ $pages = get_existpages();
176+ }
177+ if (! empty($filter)) {
178+ $pregfilter = '/' . str_replace('/', '\/', $filter) . '/';
179+ foreach($pages as $file => $page) {
180+ if (! preg_match($pregfilter, $page)) {
181+ unset($pages[$file]);
182+ }
183+ }
184+ }
185+ if (! empty($except)) {
186+ $pregexcept = '/' . str_replace('/', '\/', $except) . '/';
187+ foreach($pages as $file => $page) {
188+ if (preg_match($pregexcept, $page)) {
189+ unset($pages[$file]);
190+ }
191+ }
192+ }
193+ return $pages;
194+ }
195+
196+ /**
197+ * Check if the page is editable or not
198+ *
199+ * PukiWIki API Extension
200+ *
201+ * @param string $page
202+ * @return boolean
203+ */
204+ function is_editable($page)
205+ {
206+ global $cantedit;
207+ if ($this->conf['ignore_freeze']) {
208+ $editable = ! in_array($page, $cantedit);
209+ } else {
210+ $editable = (! is_freeze($page) and ! in_array($page, $cantedit) );
211+ }
212+ return $editable;
213+ }
209214 }
210215
211216 //////////////////////////////////
212217 class PluginRegexpView
213218 {
214- // static
215- var $msg;
216- // var
217- var $plugin = 'regexp';
218- var $options;
219- var $conf;
220- var $model;
219+ // static
220+ var $msg;
221+ // var
222+ var $plugin = 'regexp';
223+ var $options;
224+ var $conf;
225+ var $model;
221226
222- function PluginRegexpView(&$model)
223- {
224- static $msg = array();
225- if (empty($msg)) {
226- $msg = array(
227- 'label' => array(
228- 'pass' => _('Admin Password'),
229- 'filter' => _('Filter Pages'),
230- 'except' => _('Except Pages'),
231- 'page' => _('A Page'),
232- 'search' => _('Search'),
233- 'replace' => _('Replace'),
234- 'msearch' => _('Multiline Search'),
235- 'mreplace' => _('Multiline Replace'),
236- 'regexp' => _('Regexp'),
237- 'notimestamp' => _('notimestamp'),
238- 'preview' => _('Preview'),
239- ),
240- 'text' => array(
241- 'pass' => '',
242- 'filter' => 'Filter pages to be processed by regular expression. <br />Ex) "^PukiWiki" =&gt; all pages starting with "PukiWiki."',
243- 'except' => 'Except pages by regular expression.',
244- 'page' => 'Specify a page to be processed. If this field is specified, "Filter Pages" is ignored.',
245- 'search' => 'The string to be replaced. Apply replacing strings to each line separately. ',
246- 'replace' => 'Ex) Search ^#ls\((.*)\)$ =&gt; Replace #lsx(\1). <br />Ex) Search &mimetex\(((?:[^;]|[^)];)*)\); =&gt; Replace $ \1 $. (with regexp check)',
247- 'msearch' => 'The multi-line strings to be replaced. Apply replacing strings to whole contents at one time. Use this when you want to include returns or line feeds. If this field is specified, "Search" is ignored. ',
248- 'mreplace' => '',
249- 'regexp' => 'Use regular expression for searching.',
250- 'notimestamp' => 'Do not change timestamps.',
251- 'preview' => '',
252- ),
253- );
254- }
227+ function __construct(&$model)
228+ {
229+ static $msg = array();
230+ if (empty($msg)) {
231+ if (UI_LANG == "ja") {
232+ $msg = array(
233+ 'label' => array(
234+ 'pass' => _('管理者パスワード'),
235+ 'filter' => _('フィルターページ'),
236+ 'except' => _('除外ページ'),
237+ 'page' => _('ページ'),
238+ 'search' => _('検索'),
239+ 'replace' => _('置換'),
240+ 'msearch' => _('複数行検索'),
241+ 'mreplace' => _('複数行置換'),
242+ 'regexp' => _('正規表現'),
243+ 'notimestamp' => _('日時更新しない'),
244+ 'preview' => _('プレビュー'),
245+ ),
246+ 'text' => array(
247+ 'pass' => '',
248+ 'filter' => 'Filter pages to be processed by regular expression. <br />Ex) "^PukiWiki" =&gt; all pages starting with "PukiWiki."',
249+ 'except' => 'Except pages by regular expression.',
250+ 'page' => 'Specify a page to be processed. If this field is specified, "Filter Pages" is ignored.',
251+ 'search' => 'The string to be replaced. Apply replacing strings to each line separately. ',
252+ 'replace' => 'Ex) Search ^#ls\((.*)\)$ =&gt; Replace #lsx(\1). <br />Ex) Search &mimetex\(((?:[^;]|[^)];)*)\); =&gt; Replace $ \1 $. (with regexp check)',
253+ 'msearch' => 'The multi-line strings to be replaced. Apply replacing strings to whole contents at one time. Use this when you want to include returns or line feeds. If this field is specified, "Search" is ignored. ',
254+ 'mreplace' => '',
255+ 'regexp' => 'Use regular expression for searching.',
256+ 'notimestamp' => 'Do not change timestamps.',
257+ 'preview' => '',
258+ ),
259+ );
260+ } else {
261+ $msg = array(
262+ 'label' => array(
263+ 'pass' => _('Admin Password'),
264+ 'filter' => _('Filter Pages'),
265+ 'except' => _('Except Pages'),
266+ 'page' => _('A Page'),
267+ 'search' => _('Search'),
268+ 'replace' => _('Replace'),
269+ 'msearch' => _('Multiline Search'),
270+ 'mreplace' => _('Multiline Replace'),
271+ 'regexp' => _('Regexp'),
272+ 'notimestamp' => _('notimestamp'),
273+ 'preview' => _('Preview'),
274+ ),
275+ 'text' => array(
276+ 'pass' => '',
277+ 'filter' => 'Filter pages to be processed by regular expression. <br />Ex) "^PukiWiki" =&gt; all pages starting with "PukiWiki."',
278+ 'except' => 'Except pages by regular expression.',
279+ 'page' => 'Specify a page to be processed. If this field is specified, "Filter Pages" is ignored.',
280+ 'search' => 'The string to be replaced. Apply replacing strings to each line separately. ',
281+ 'replace' => 'Ex) Search ^#ls\((.*)\)$ =&gt; Replace #lsx(\1). <br />Ex) Search &mimetex\(((?:[^;]|[^)];)*)\); =&gt; Replace $ \1 $. (with regexp check)',
282+ 'msearch' => 'The multi-line strings to be replaced. Apply replacing strings to whole contents at one time. Use this when you want to include returns or line feeds. If this field is specified, "Search" is ignored. ',
283+ 'mreplace' => '',
284+ 'regexp' => 'Use regular expression for searching.',
285+ 'notimestamp' => 'Do not change timestamps.',
286+ 'preview' => '',
287+ ),
288+ );
289+ }
290+ }
255291
256- $this->msg = &$msg;
257- $this->model = &$model;
258- $this->options = &$model->options;
259- $this->conf = &$model->conf;
260- }
292+ $this->msg = &$msg;
293+ $this->model = &$model;
294+ $this->options = &$model->options;
295+ $this->conf = &$model->conf;
296+ }
297+
298+ function PluginRegexpView() {
299+ $this->__construct();
300+ }
261301
262- function login()
263- {
264- if ($this->conf['adminonly'] === FALSE) return TRUE;
265- global $vars;
266- $pass = isset($vars['pass']) ? $vars['pass'] : $this->getcookie('pass');
267- if (pkwk_login($pass)) {
268- $this->setcookie('pass', $pass);
269- return TRUE;
270- } else {
271- return FALSE;
272- }
273- }
302+ function login()
303+ {
304+ if ($this->conf['adminonly'] === FALSE) return TRUE;
305+ global $vars;
306+ $pass = isset($vars['pass']) ? $vars['pass'] : $this->getcookie('pass');
307+ if (pkwk_login($pass)) {
308+ $this->setcookie('pass', $pass);
309+ return TRUE;
310+ } else {
311+ return FALSE;
312+ }
313+ }
274314
275- /**
276- * Get cookie
277- *
278- * @param string $key
279- * @return mixed
280- */
281- function getcookie($key)
282- {
283- $key = 'plugin_regexp_' . $key;
284- return isset($_COOKIE[$key]) ? unserialize($_COOKIE[$key]) : null;
285- }
315+ /**
316+ * Get cookie
317+ *
318+ * @param string $key
319+ * @return mixed
320+ */
321+ function getcookie($key)
322+ {
323+ $key = 'plugin_regexp_' . $key;
324+ return isset($_COOKIE[$key]) ? unserialize($_COOKIE[$key]) : null;
325+ }
286326
287- /**
288- * Set cookie
289- *
290- * @param string $key
291- * @param mixed $val
292- * @return void
293- */
294- function setcookie($key, $val)
295- {
296- global $script;
297- $parsed = parse_url($script);
298- $path = $this->get_dirname($parsed['path']);
299- $key = 'plugin_regexp_' . $key;
300- setcookie($key, serialize($val), 0, $path);
301- $_COOKIE[$key] = serialize($val);
302- }
327+ /**
328+ * Set cookie
329+ *
330+ * @param string $key
331+ * @param mixed $val
332+ * @return void
333+ */
334+ function setcookie($key, $val)
335+ {
336+ global $script;
337+ $parsed = parse_url($script);
338+ $path = $this->get_dirname($parsed['path']);
339+ $key = 'plugin_regexp_' . $key;
340+ setcookie($key, serialize($val), 0, $path);
341+ $_COOKIE[$key] = serialize($val);
342+ }
303343
304- function result($pages)
305- {
306- $links = array();
307- foreach ($pages as $page) {
308- $links[] = make_pagelink($page);
309- }
310- $msg = implode("<br />\n", $links);
311- $body = '<p>The following pages were replaced.</p><div>' . $msg . '</div>';
312- return $body;
313- }
344+ function result($pages)
345+ {
346+ $links = array();
347+ foreach ($pages as $page) {
348+ $links[] = make_pagelink($page);
349+ }
350+ $msg = implode("<br />\n", $links);
351+ $body = '<p>The following pages were replaced.</p><div>' . $msg . '</div>';
352+ return $body;
353+ }
314354
315- function preview($page, $diff, $pages)
316- {
317- global $script;
318- if ($page == '' || $diff == '') {
319- return '<div>No page found or nothing changed.</div>';
320- }
321- unset($this->options['pass']);
322- unset($this->options['pcmd']);
323- foreach ($this->options as $key => $val) {
324- $this->setcookie($key, $val);
325- }
355+ function preview($page, $diff, $pages)
356+ {
357+ global $script;
358+ if ($page == '' || $diff == '') {
359+ return '<div>No page found or nothing changed.</div>';
360+ }
361+ unset($this->options['pass']);
362+ unset($this->options['pcmd']);
363+ foreach ($this->options as $key => $val) {
364+ $this->setcookie($key, $val);
365+ }
326366
327- $msg = '<div>A preview, <b>' . htmlspecialchars($page) . '</b></div>';
328- //$diff = '<pre>' . htmlspecialchars($diff) . '</pre>';
329- $msg .= '<pre>' . diff_style_to_css(htmlspecialchars($diff)) . '</pre>'; // Pukiwiki API
367+ $msg = '<div>A preview, <b>' . htmlsc($page) . '</b></div>';
368+ //$diff = '<pre>' . htmlsc($diff) . '</pre>';
369+ $msg .= '<pre>' . diff_style_to_css(htmlsc($diff)) . '</pre>'; // Pukiwiki API
330370
331- $msg .= '<div>List of target pages (Result of Filter Pages) </div>';
332- $msg .= '<ul>';
333- foreach ($pages as $apage) {
334- $msg .= '<li>' . make_pagelink($apage) . '</li>';
335- }
336- $msg .= '</ul>';
371+ $msg .= '<div>List of target pages (Result of Filter Pages) </div>';
372+ $msg .= '<ul>';
373+ foreach ($pages as $apage) {
374+ $msg .= '<li>' . make_pagelink($apage) . '</li>';
375+ }
376+ $msg .= '</ul>';
337377
338- $form = array();
339- $form[] = '<form action="' . $script . '?cmd=' . $this->plugin . '" method="post">';
340- $form[] = '<div>';
341- $form[] = ' Do you want to replace all pages? ';
342- $form[] = ' <input type="hidden" name="cmd" value="regexp" />';
343- $form[] = ' <input type="hidden" name="pcmd" value="replace" />';
344- foreach ($this->options as $key => $val) {
345- $form[] = ' <input type="hidden" name="' . $key . '" value="' . $val . '" />';
346- }
347- $form[] = ' <input type="submit" name="ok" value="Yes" /><br />';
348- $form[] = '</div>';
349- $form[] = '</form>';
350- $form = implode("\n", $form);
351- return $msg . $form;
352- }
378+ $form = array();
379+ $form[] = '<form action="' . $script . '?cmd=' . $this->plugin . '" method="post">';
380+ $form[] = '<div>';
381+ $form[] = ' Do you want to replace all pages? ';
382+ $form[] = ' <input type="hidden" name="cmd" value="regexp" />';
383+ $form[] = ' <input type="hidden" name="pcmd" value="replace" />';
384+ foreach ($this->options as $key => $val) {
385+ $form[] = ' <input type="hidden" name="' . $key . '" value="' . $val . '" />';
386+ }
387+ $form[] = ' <input type="submit" name="ok" value="Yes" /><br />';
388+ $form[] = '</div>';
389+ $form[] = '</form>';
390+ $form = implode("\n", $form);
391+ return $msg . $form;
392+ }
353393
354- /**
355- * Show form
356- *
357- * @param string $msg
358- * @return string html
359- */
360- function showform($msg = "")
361- {
362- global $script;
363- foreach ($this->options as $key => $val) {
364- ${$key} = $this->getcookie($key);
365- if (is_null(${$key})) ${$key} = $val;
366- }
367- $regexp = ($regexp == 'on') ? ' checked="checked"' : '';
368- $notimestamp = ($notimestamp == 'on') ? ' checked="checked"' : '';
394+ /**
395+ * Show form
396+ *
397+ * @param string $msg
398+ * @return string html
399+ */
400+ function showform($msg = "")
401+ {
402+ global $script;
403+ foreach ($this->options as $key => $val) {
404+ ${$key} = $this->getcookie($key);
405+ if (is_null(${$key})) ${$key} = $val;
406+ }
407+ $regexp = ($regexp == 'on') ? ' checked="checked"' : '';
408+ $notimestamp = ($notimestamp == 'on') ? ' checked="checked"' : '';
369409
370- $form = array();
371- $form[] = '<form action="' . $script . '?cmd=' . $this->plugin . '" method="post">';
372- $form[] = '<div class="ie5"><table class="style_table" cellspacing="1" border="0"><tbody>';
373- if ($this->conf['adminonly']) {
374- $form[] = '<tr><td class="style_td">' . $this->msg['label']['pass'] .
375- '</td><td class="style_td"><input type="password" name="pass" size="24" value="' . $pass . '" />' .
376- '</td><td class="style_td">' . $this->msg['text']['pass'] . '</td></tr>';
377- }
378- $form[] = '<tr><td class="style_td">' . $this->msg['label']['filter'] .
379- '</td><td class="style_td"><input type="text" name="filter" size="42" value="' . $filter . '" />' .
380- '</td><td class="style_td">' . $this->msg['text']['filter'] . '</td></tr>';
381- $form[] = '<tr><td class="style_td">' . $this->msg['label']['except'] .
382- '</td><td class="style_td"><input type="text" name="except" size="42" value="' . $except . '" />' .
383- '</td><td class="style_td">' . $this->msg['text']['except'] . '</td></tr>';
384- $form[] = '<tr><td class="style_td">' . $this->msg['label']['page'] .
385- '</td><td class="style_td"><input type="text" name="page" size="42" value="' . $page . '" />' .
386- '</td><td class="style_td">' . $this->msg['text']['page'] . '</td></tr>';
387- $form[] = '<tr><td class="style_td"><label for="regexp">' . $this->msg['label']['regexp'] . '</label>' .
388- '</td><td class="style_td"><input type="checkbox" name="regexp" id="regexp" value="on"' . $regexp . '/>' .
389- '</td><td class="style_td">' . $this->msg['text']['regexp'] . '</td></tr>';
390- $form[] = '<tr><td class="style_td">' . $this->msg['label']['search'] .
391- '</td><td class="style_td"><input type="text" name="search" size="42" value="' . $search . '" />' .
392- '</td><td class="style_td">' . $this->msg['text']['search'] . '</td></tr>';
393- $form[] = '<tr><td class="style_td">' . $this->msg['label']['replace'] .
394- '</td><td class="style_td"><input type="text" name="replace" size="42" value="' . $replace . '" />' .
395- '</td><td class="style_td">' . $this->msg['text']['replace'] . '</td></tr>';
396- $form[] = '<tr><td class="style_td">' . $this->msg['label']['msearch'] .
397- '</td><td class="style_td"><textarea name="msearch" rows="3" cols="40">' . $msearch . '</textarea>' .
398- '</td><td class="style_td">' . $this->msg['text']['msearch'] . '</td></tr>';
399- $form[] = '<tr><td class="style_td">' . $this->msg['label']['mreplace'] .
400- '</td><td class="style_td"><textarea name="mreplace" rows="3" cols="40">' . $mreplace . '</textarea>' .
401- '</td><td class="style_td">' . $this->msg['text']['mreplace'] . '</td></tr>';
402- $form[] = '<tr><td class="style_td"><label for="notimestamp">' . $this->msg['label']['notimestamp'] . '</label>' .
403- '</td><td class="style_td"><input type="checkbox" name="notimestamp" id="notimestamp" value="on"' . $notimestamp . '/>' .
404- '</td><td class="style_td">' . $this->msg['text']['notimestamp'] . '</td></tr>';
405- $form[] = '</tbody></table></div>';
406- $form[] = '<div>';
407- $form[] = ' <input type="hidden" name="cmd" value="regexp" />';
408- $form[] = ' <input type="hidden" name="pcmd" value="preview" />';
409- $form[] = ' <input type="submit" name="submit" id="preview" value="' . $this->msg['label']['preview'] . '" />';
410- $form[] = '</div>';
411- $form[] = '</form>';
412- $form = implode("\n", $form);
410+ $form = array();
411+ $form[] = '<form action="' . $script . '?cmd=' . $this->plugin . '" method="post">';
412+ $form[] = '<div class="ie5"><table class="style_table" cellspacing="1" border="0"><tbody>';
413+ if ($this->conf['adminonly']) {
414+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['pass'] .
415+ '</td><td class="style_td"><input type="password" name="pass" size="24" value="' . $pass . '" />' .
416+ '</td><td class="style_td">' . $this->msg['text']['pass'] . '</td></tr>';
417+ }
418+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['filter'] .
419+ '</td><td class="style_td"><input type="text" name="filter" size="42" value="' . $filter . '" />' .
420+ '</td><td class="style_td">' . $this->msg['text']['filter'] . '</td></tr>';
421+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['except'] .
422+ '</td><td class="style_td"><input type="text" name="except" size="42" value="' . $except . '" />' .
423+ '</td><td class="style_td">' . $this->msg['text']['except'] . '</td></tr>';
424+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['page'] .
425+ '</td><td class="style_td"><input type="text" name="page" size="42" value="' . $page . '" />' .
426+ '</td><td class="style_td">' . $this->msg['text']['page'] . '</td></tr>';
427+ $form[] = '<tr><td class="style_td"><label for="regexp">' . $this->msg['label']['regexp'] . '</label>' .
428+ '</td><td class="style_td"><input type="checkbox" name="regexp" id="regexp" value="on"' . $regexp . '/>' .
429+ '</td><td class="style_td">' . $this->msg['text']['regexp'] . '</td></tr>';
430+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['search'] .
431+ '</td><td class="style_td"><input type="text" name="search" size="42" value="' . $search . '" />' .
432+ '</td><td class="style_td">' . $this->msg['text']['search'] . '</td></tr>';
433+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['replace'] .
434+ '</td><td class="style_td"><input type="text" name="replace" size="42" value="' . $replace . '" />' .
435+ '</td><td class="style_td">' . $this->msg['text']['replace'] . '</td></tr>';
436+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['msearch'] .
437+ '</td><td class="style_td"><textarea name="msearch" rows="3" cols="40">' . $msearch . '</textarea>' .
438+ '</td><td class="style_td">' . $this->msg['text']['msearch'] . '</td></tr>';
439+ $form[] = '<tr><td class="style_td">' . $this->msg['label']['mreplace'] .
440+ '</td><td class="style_td"><textarea name="mreplace" rows="3" cols="40">' . $mreplace . '</textarea>' .
441+ '</td><td class="style_td">' . $this->msg['text']['mreplace'] . '</td></tr>';
442+ $form[] = '<tr><td class="style_td"><label for="notimestamp">' . $this->msg['label']['notimestamp'] . '</label>' .
443+ '</td><td class="style_td"><input type="checkbox" name="notimestamp" id="notimestamp" value="on"' . $notimestamp . '/>' .
444+ '</td><td class="style_td">' . $this->msg['text']['notimestamp'] . '</td></tr>';
445+ $form[] = '</tbody></table></div>';
446+ $form[] = '<div>';
447+ $form[] = ' <input type="hidden" name="cmd" value="regexp" />';
448+ $form[] = ' <input type="hidden" name="pcmd" value="preview" />';
449+ $form[] = ' <input type="submit" name="submit" id="preview" value="' . $this->msg['label']['preview'] . '" />';
450+ $form[] = '</div>';
451+ $form[] = '</form>';
452+ $form = implode("\n", $form);
413453
414- if ($msg != '') {
415- $msg = '<p><b>' . $msg . '</b></p>';
416- }
417- return $msg . $form;
418- }
419- /**
420- * Get the dirname of a path
421- *
422- * PHP API Extension
423- *
424- * PHP's dirname works as
425- * <code>
426- * 'Page/' => '.', 'Page/a' => 'Page', 'Page' => '.'
427- * </code>
428- * This function works as
429- * <code>
430- * 'Page/' => 'Page', 'Page/a' => 'Page', 'Page' => ''
431- * </code>
432- *
433- * @access public
434- * @static
435- * @param string $path
436- * @return string dirname
437- * @version $Id: v 1.0 2008-06-05 11:14:46 sonots $
438- */
439- function get_dirname($path)
440- {
441- if (($pos = strrpos($path, '/')) !== false) {
442- return substr($path, 0, $pos);
443- } else {
444- return '';
445- }
446- }
454+ if ($msg != '') {
455+ $msg = '<p><b>' . $msg . '</b></p>';
456+ }
457+ return $msg . $form;
458+ }
459+ /**
460+ * Get the dirname of a path
461+ *
462+ * PHP API Extension
463+ *
464+ * PHP's dirname works as
465+ * <code>
466+ * 'Page/' => '.', 'Page/a' => 'Page', 'Page' => '.'
467+ * </code>
468+ * This function works as
469+ * <code>
470+ * 'Page/' => 'Page', 'Page/a' => 'Page', 'Page' => ''
471+ * </code>
472+ *
473+ * @access public
474+ * @static
475+ * @param string $path
476+ * @return string dirname
477+ * @version $Id: v 1.0 2008-06-05 11:14:46 sonots $
478+ */
479+ function get_dirname($path)
480+ {
481+ if (($pos = strrpos($path, '/')) !== false) {
482+ return substr($path, 0, $pos);
483+ } else {
484+ return '';
485+ }
486+ }
447487 }
448488
449489 // php extension
450490 if (! function_exists('_')) {
451- function &_($str)
452- {
453- return $str;
454- }
491+ function &_($str)
492+ {
493+ return $str;
494+ }
455495 }
456496
457497 //////////////////////////////////
458498 function plugin_regexp_init()
459499 {
460- global $plugin_regexp_name;
461- if (class_exists('PluginRegexpUnitTest')) {
462- $plugin_regexp_name = 'PluginRegexpUnitTest';
463- } elseif (class_exists('PluginRegexpUser')) {
464- $plugin_regexp_name = 'PluginRegexpUser';
465- } else {
466- $plugin_regexp_name = 'PluginRegexp';
467- }
500+ global $plugin_regexp_name;
501+ if (class_exists('PluginRegexpUnitTest')) {
502+ $plugin_regexp_name = 'PluginRegexpUnitTest';
503+ } elseif (class_exists('PluginRegexpUser')) {
504+ $plugin_regexp_name = 'PluginRegexpUser';
505+ } else {
506+ $plugin_regexp_name = 'PluginRegexp';
507+ }
468508 }
469509 function plugin_regexp_action()
470510 {
471- global $plugin_regexp, $plugin_regexp_name;
472- $plugin_regexp = new $plugin_regexp_name();
473- return call_user_func(array(&$plugin_regexp, 'action'));
511+ global $plugin_regexp, $plugin_regexp_name;
512+ $plugin_regexp = new $plugin_regexp_name();
513+ return call_user_func(array(&$plugin_regexp, 'action'));
474514 }
475515
476516 if (! defined('INIT_DIR')) // if not Plus!
477- if (file_exists(DATA_HOME . 'init/regexp.ini.php'))
478- include_once(DATA_HOME . 'init/regexp.ini.php');
517+ if (file_exists(DATA_HOME . 'init/regexp.ini.php'))
518+ include_once(DATA_HOME . 'init/regexp.ini.php');
479519
480520 ?>