• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Révision07ed08515585506b222864cb1ceb0a19050e34f7 (tree)
l'heure2016-12-16 08:43:58
Auteurnight1ynx <night1ynxd@gmai...>
Commiternight1ynx

Message de Log

Fix errors in PHP 7.0+

Change Summary

Modification

--- /dev/null
+++ b/lib/compat.php
@@ -0,0 +1,44 @@
1+<?php
2+/**
3+ * Forward/Backward compatibility layer
4+ *
5+ * @copyright 2016 night1ynx
6+ * @license GPLv2 or later
7+ */
8+
9+/**
10+ * E_USER_DEPRECATED was introduced since PHP 5.3
11+ */
12+if (! defined('E_USER_DEPRECATED')) {
13+ define('E_USER_DEPRECATED', E_USER_WARNING);
14+}
15+
16+if (! function_exists('ereg')) {
17+ /**
18+ * @deprecated
19+ */
20+ function ereg($pattern, $string, &$regs = array()) {
21+ trigger_error('ereg() was removed in PHP 7.0', E_USER_DEPRECATED);
22+ return mb_ereg($pattern, $string, $regs);
23+ }
24+}
25+
26+if (! function_exists('ereg_replace')) {
27+ /**
28+ * @deprecated
29+ */
30+ function ereg_replace($pattern, $replacement, $string) {
31+ trigger_error('ereg_replace() was removed in PHP 7.0', E_USER_DEPRECATED);
32+ return mb_ereg_replace($pattern, $replacement, $string);
33+ }
34+}
35+
36+if (! function_exists('split')) {
37+ /**
38+ * @deprecated
39+ */
40+ function split($pattern, $string, $limit = -1) {
41+ trigger_error('split() was removed in PHP 7.0', E_USER_DEPRECATED);
42+ return mb_split($pattern, $string, $limit);
43+ }
44+}
--- a/lib/config.php
+++ b/lib/config.php
@@ -41,7 +41,7 @@ class Config
4141 if (! is_page($this->page)) return FALSE;
4242
4343 $this->objs = array();
44- $obj = & new ConfigTable('');
44+ $obj = new ConfigTable('');
4545 $matches = array();
4646
4747 foreach (get_source($this->page) as $line) {
@@ -59,22 +59,22 @@ class Config
5959
6060 if ($level == 1) {
6161 $this->objs[$obj->title] = $obj;
62- $obj = & new ConfigTable($line);
62+ $obj = new ConfigTable($line);
6363 } else {
6464 if (! is_a($obj, 'ConfigTable_Direct'))
65- $obj = & new ConfigTable_Direct('', $obj);
65+ $obj = new ConfigTable_Direct('', $obj);
6666 $obj->set_key($line);
6767 }
6868
6969 } else if ($head == '-' && $level > 1) {
7070 if (! is_a($obj, 'ConfigTable_Direct'))
71- $obj = & new ConfigTable_Direct('', $obj);
71+ $obj = new ConfigTable_Direct('', $obj);
7272 $obj->add_value($line);
7373
7474 } else if ($head == '|' && preg_match('/^\|(.+)\|\s*$/', $line, $matches)) {
7575 // Table row
7676 if (! is_a($obj, 'ConfigTable_Sequential'))
77- $obj = & new ConfigTable_Sequential('', $obj);
77+ $obj = new ConfigTable_Sequential('', $obj);
7878 // Trim() each table cell
7979 $obj->add_value(array_map('trim', explode('|', $matches[1])));
8080 } else {
@@ -111,7 +111,7 @@ class Config
111111 function & get_object($title)
112112 {
113113 if (! isset($this->objs[$title]))
114- $this->objs[$title] = & new ConfigTable('*' . trim($title) . "\n");
114+ $this->objs[$title] = new ConfigTable('*' . trim($title) . "\n");
115115 return $this->objs[$title];
116116 }
117117
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -20,7 +20,7 @@ function convert_html($lines)
2020
2121 if (! is_array($lines)) $lines = explode("\n", $lines);
2222
23- $body = & new Body(++$contents_id);
23+ $body = new Body(++$contents_id);
2424 $body->parse($lines);
2525
2626 return $body->toString();
@@ -192,7 +192,7 @@ class Inline extends Element
192192
193193 function & toPara($class = '')
194194 {
195- $obj = & new Paragraph('', $class);
195+ $obj = new Paragraph('', $class);
196196 $obj->insert($this);
197197 return $obj;
198198 }
@@ -580,7 +580,7 @@ class Table extends Element
580580 $is_template = ($this->type == 'c');
581581 $row = array();
582582 foreach ($cells as $cell)
583- $row[] = & new TableCell($cell, $is_template);
583+ $row[] = new TableCell($cell, $is_template);
584584 $this->elements[] = $row;
585585 }
586586
@@ -860,7 +860,7 @@ class Body extends Element
860860 function Body($id)
861861 {
862862 $this->id = $id;
863- $this->contents = & new Element();
863+ $this->contents = new Element();
864864 $this->contents_last = & $this->contents;
865865 parent::Element();
866866 }
--- a/lib/func.php
+++ b/lib/func.php
@@ -621,7 +621,7 @@ function get_glossary_pattern(& $pages, $min_len = -1)
621621 {
622622 global $WikiName, $autoglossary, $nowikiname;
623623
624- $config = &new Config('Glossary');
624+ $config = new Config('Glossary');
625625 $config->read();
626626 $ignorepages = $config->get('IgnoreList');
627627 $forceignorepages = $config->get('ForceIgnoreList');
@@ -657,7 +657,7 @@ function get_autolink_pattern(& $pages, $min_len = -1)
657657 {
658658 global $WikiName, $autolink, $nowikiname;
659659
660- $config = &new Config('AutoLink');
660+ $config = new Config('AutoLink');
661661 $config->read();
662662 $ignorepages = $config->get('IgnoreList');
663663 $forceignorepages = $config->get('ForceIgnoreList');
--- a/lib/init.php
+++ b/lib/init.php
@@ -352,7 +352,7 @@ $BracketName = '(?!\s):?[^\r\n\t\f\[\]<>#&":]+:?(?<!\s)';
352352 $InterWikiName = '(\[\[)?((?:(?!\s|:|\]\]).)+):(.+)(?(1)\]\])';
353353
354354 // 注釈
355-$NotePattern = '/\(\(((?:(?>(?:(?!\(\()(?!\)\)(?:[^\)]|$)).)+)|(?R))*)\)\)/ex';
355+$NotePattern = '/\(\(((?:(?>(?:(?!\(\()(?!\)\)(?:[^\)]|$)).)+)|(?R))*)\)\)/x';
356356
357357 /////////////////////////////////////////////////
358358 // 初期設定(ユーザ定義ルール読み込み)
@@ -380,5 +380,3 @@ $line_rules = array_merge(array(
380380 '&amp;(#[0-9]+|#x[0-9a-f]+|' . $entity_pattern . ');' => '&$1;',
381381 "\r" => '<br />' . "\n", /* 行末にチルダは改行 */
382382 ), $line_rules);
383-
384-?>
--- a/lib/lang.php
+++ b/lib/lang.php
@@ -110,7 +110,7 @@ function get_language($level = 0)
110110 for($i=0; $i < $level; $i++){
111111 if ($i == $level) return DEFAULT_LANG;
112112 // 指定関数の実行
113- $_x = $obj_lng->$lng_func[$i]();
113+ $_x = $obj_lng->{$lng_func[$i]}();
114114 if (! is_array($_x)) continue;
115115
116116 foreach($_x as $_lang) {
--- a/lib/link.php
+++ b/lib/link.php
@@ -261,7 +261,7 @@ function & links_get_objects($page, $refresh = FALSE)
261261 static $obj;
262262
263263 if (! isset($obj) || $refresh)
264- $obj = & new InlineConverter(NULL, array('note'));
264+ $obj = new InlineConverter(NULL, array('note'));
265265
266266 $result = $obj->get_objects(join('', preg_grep('/^(?!\/\/|\s)./', get_source($page))), $page);
267267 return $result;
--- a/lib/openid/Auth/OpenID/Consumer.php
+++ b/lib/openid/Auth/OpenID/Consumer.php
@@ -268,9 +268,9 @@ class Auth_OpenID_Consumer {
268268 $this->session =& $session;
269269
270270 if ($consumer_cls !== null) {
271- $this->consumer =& new $consumer_cls($store);
271+ $this->consumer = new $consumer_cls($store);
272272 } else {
273- $this->consumer =& new Auth_OpenID_GenericConsumer($store);
273+ $this->consumer = new Auth_OpenID_GenericConsumer($store);
274274 }
275275
276276 $this->_token_key = $this->session_key_prefix . $this->_token_suffix;
--- a/lib/openid/Auth/OpenID/Server.php
+++ b/lib/openid/Auth/OpenID/Server.php
@@ -1097,7 +1097,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request {
10971097 in OpenID 1.x immediate mode.');
10981098 }
10991099
1100- $setup_request =& new Auth_OpenID_CheckIDRequest(
1100+ $setup_request = new Auth_OpenID_CheckIDRequest(
11011101 $this->identity,
11021102 $this->return_to,
11031103 $this->trust_root,
@@ -1677,9 +1677,9 @@ class Auth_OpenID_Server {
16771677 function Auth_OpenID_Server(&$store, $op_endpoint=null)
16781678 {
16791679 $this->store =& $store;
1680- $this->signatory =& new Auth_OpenID_Signatory($this->store);
1681- $this->encoder =& new Auth_OpenID_SigningEncoder($this->signatory);
1682- $this->decoder =& new Auth_OpenID_Decoder($this);
1680+ $this->signatory = new Auth_OpenID_Signatory($this->store);
1681+ $this->encoder = new Auth_OpenID_SigningEncoder($this->signatory);
1682+ $this->decoder = new Auth_OpenID_Decoder($this);
16831683 $this->op_endpoint = $op_endpoint;
16841684 $this->negotiator =& Auth_OpenID_getDefaultNegotiator();
16851685 }
--- a/lib/openid/Auth/Yadis/XRDS.php
+++ b/lib/openid/Auth/Yadis/XRDS.php
@@ -352,7 +352,7 @@ class Auth_Yadis_XRDS {
352352 $services = $this->parser->evalXPath('xrd:Service', $this->xrdNode);
353353
354354 foreach ($services as $node) {
355- $s =& new Auth_Yadis_Service();
355+ $s = new Auth_Yadis_Service();
356356 $s->element = $node;
357357 $s->parser =& $this->parser;
358358
@@ -475,4 +475,4 @@ class Auth_Yadis_XRDS {
475475 }
476476 }
477477
478-?>
\ No newline at end of file
478+?>
--- a/lib/pukiwiki.php
+++ b/lib/pukiwiki.php
@@ -41,6 +41,7 @@ if (! defined('DATA_HOME')) define('DATA_HOME', '');
4141
4242 if (! defined('LIB_DIR')) define('LIB_DIR', '');
4343
44+require(LIB_DIR . 'compat.php');
4445 require(LIB_DIR . 'func.php');
4546 require(LIB_DIR . 'file.php');
4647 require(LIB_DIR . 'funcplus.php');
--- a/plugin/attach.inc.php
+++ b/plugin/attach.inc.php
@@ -124,7 +124,7 @@ function plugin_attach_convert()
124124
125125 $ret = '';
126126 if (! $nolist) {
127- $obj = & new AttachPages($page);
127+ $obj = new AttachPages($page);
128128 $ret .= $obj->toString($page, TRUE);
129129 }
130130 if (! $noform) {
@@ -199,7 +199,7 @@ function attach_filelist()
199199
200200 $page = isset($vars['page']) ? $vars['page'] : '';
201201
202- $obj = & new AttachPages($page, 0);
202+ $obj = new AttachPages($page, 0);
203203
204204 if (! isset($obj->pages[$page])) {
205205 return '';
@@ -333,7 +333,7 @@ function attach_doupload(&$file, $page, $pass=NULL, $temp='', $copyright=FALSE,
333333
334334 if ($must_compress && is_uploaded_file($file['tmp_name'])) {
335335 if (PLUGIN_ATTACH_COMPRESS_TYPE == 'TGZ' && exist_plugin('dump')) {
336- $obj = & new AttachFile($page, $file['name'] . '.tgz');
336+ $obj = new AttachFile($page, $file['name'] . '.tgz');
337337 if ($obj->exist)
338338 return array('result'=>FALSE,
339339 'msg'=>$_attach_messages['err_exists']);
@@ -349,7 +349,7 @@ function attach_doupload(&$file, $page, $pass=NULL, $temp='', $copyright=FALSE,
349349 @unlink($tar->filename);
350350 } else
351351 if (PLUGIN_ATTACH_COMPRESS_TYPE == 'GZ' && extension_loaded('zlib')) {
352- $obj = & new AttachFile($page, $file['name'] . '.gz');
352+ $obj = new AttachFile($page, $file['name'] . '.gz');
353353 if ($obj->exist)
354354 return array('result'=>FALSE,
355355 'msg'=>$_attach_messages['err_exists']);
@@ -366,7 +366,7 @@ function attach_doupload(&$file, $page, $pass=NULL, $temp='', $copyright=FALSE,
366366 @unlink($file['tmp_name']);
367367 } else
368368 if (PLUGIN_ATTACH_COMPRESS_TYPE == 'ZIP' && class_exists('ZipArchive')) {
369- $obj = & new AttachFile($page, $file['name'] . '.zip');
369+ $obj = new AttachFile($page, $file['name'] . '.zip');
370370 if ($obj->exist)
371371 return array('result'=>FALSE,
372372 'msg'=>$_attach_messages['err_exists']);
@@ -382,7 +382,7 @@ function attach_doupload(&$file, $page, $pass=NULL, $temp='', $copyright=FALSE,
382382 }
383383 } else {
384384 //miko
385- $obj = & new AttachFile($page, $file['name']);
385+ $obj = new AttachFile($page, $file['name']);
386386 if ($obj->exist)
387387 return array('result'=>FALSE,
388388 'msg'=>$_attach_messages['err_exists']);
@@ -506,7 +506,7 @@ function attach_info($err = '')
506506
507507 check_editable($refer, true, true);
508508
509- $obj = & new AttachFile($refer, $file, $age);
509+ $obj = new AttachFile($refer, $file, $age);
510510 return $obj->getstatus() ?
511511 $obj->info($err) :
512512 array('msg'=>$_attach_messages['err_notfound']);
@@ -523,7 +523,7 @@ function attach_delete()
523523 if (is_freeze($refer) || ! is_editable($refer))
524524 return array('msg'=>$_attach_messages['err_noparm']);
525525
526- $obj = & new AttachFile($refer, $file, $age);
526+ $obj = new AttachFile($refer, $file, $age);
527527 if (! $obj->getstatus())
528528 return array('msg'=>$_attach_messages['err_notfound']);
529529
@@ -542,7 +542,7 @@ function attach_freeze($freeze)
542542 if (is_freeze($refer) || ! is_editable($refer)) {
543543 return array('msg'=>$_attach_messages['err_noparm']);
544544 } else {
545- $obj = & new AttachFile($refer, $file, $age);
545+ $obj = new AttachFile($refer, $file, $age);
546546 return $obj->getstatus() ?
547547 $obj->freeze($freeze, $pass) :
548548 array('msg'=>$_attach_messages['err_notfound']);
@@ -561,7 +561,7 @@ function attach_rename()
561561 if (is_freeze($refer) || ! is_editable($refer)) {
562562 return array('msg'=>$_attach_messages['err_noparm']);
563563 }
564- $obj = & new AttachFile($refer, $file, $age);
564+ $obj = new AttachFile($refer, $file, $age);
565565 if (! $obj->getstatus())
566566 return array('msg'=>$_attach_messages['err_notfound']);
567567
@@ -577,7 +577,7 @@ function attach_open()
577577 ${$var} = isset($vars[$var]) ? $vars[$var] : '';
578578 }
579579
580- $obj = & new AttachFile($refer, $file, $age);
580+ $obj = new AttachFile($refer, $file, $age);
581581 return $obj->getstatus() ?
582582 $obj->open() :
583583 array('msg'=>$_attach_messages['err_notfound']);
@@ -592,7 +592,7 @@ function attach_list()
592592
593593 $refer = isset($vars['refer']) ? $vars['refer'] : '';
594594
595- $obj = & new AttachPages($refer);
595+ $obj = new AttachPages($refer);
596596
597597 $msg = $_attach_messages[($refer == '') ? 'msg_listall' : 'msg_listpage'];
598598 $body = ($refer == '' || isset($obj->pages[$refer])) ?
@@ -714,7 +714,7 @@ EOD;
714714 </form>
715715 EOD;
716716 if ($listview) {
717- $obj = & new AttachPages($page);
717+ $obj = new AttachPages($page);
718718 $body = ($refer == '' || isset($obj->pages[$page])) ?
719719 $obj->toRender($page, FALSE) :
720720 $_attach_messages['err_noexist'];
@@ -1067,7 +1067,7 @@ class AttachFiles
10671067
10681068 function add($file, $age)
10691069 {
1070- $this->files[$file][$age] = & new AttachFile($this->page, $file, $age);
1070+ $this->files[$file][$age] = new AttachFile($this->page, $file, $age);
10711071 }
10721072
10731073 // ファイル一覧を取得
@@ -1192,7 +1192,7 @@ class AttachPages
11921192 $_file = decode($matches[2]);
11931193 $_age = isset($matches[3]) ? $matches[3] : 0;
11941194 if (! isset($this->pages[$_page])) {
1195- $this->pages[$_page] = & new AttachFiles($_page);
1195+ $this->pages[$_page] = new AttachFiles($_page);
11961196 }
11971197 $this->pages[$_page]->add($_file, $_age);
11981198 }
--- a/plugin/dav.inc.php
+++ b/plugin/dav.inc.php
@@ -517,7 +517,7 @@ function plugin_dav_maketree0()
517517 // 現状は、添付ファイル非表示の場合は抑止
518518 if (!$attach_link) return $root;
519519
520- $attaches = & new AttachPages('');
520+ $attaches = new AttachPages('');
521521 foreach($attaches->pages as $key => $val){
522522 if(check_non_list($key)) continue;
523523 if(!check_readable($key, false, false)) continue;
--- a/plugin/map.inc.php
+++ b/plugin/map.inc.php
@@ -43,13 +43,13 @@ function plugin_map_action()
4343 // Generate a tree
4444 $nodes = array();
4545 foreach ($pages as $page) {
46- $nodes[$page] = & new MapNode($page, $reverse);
46+ $nodes[$page] = new MapNode($page, $reverse);
4747 }
4848
4949 // Node not found: Because of filtererd by $non_list
5050 if (! isset($nodes[$refer])) {
5151 $vars['refer'] = $refer = $defaultpage;
52- $nodes[$refer] = & new MapNode($page, $reverse);
52+ $nodes[$refer] = new MapNode($page, $reverse);
5353 }
5454
5555 if ($reverse) {
@@ -177,7 +177,7 @@ class MapNode
177177 if ($this->parent_id == 0) $this->parent_id = -1;
178178
179179 foreach ($this->rels as $page) {
180- if (! isset($nodes[$page])) $nodes[$page] = & new MapNode($page);
180+ if (! isset($nodes[$page])) $nodes[$page] = new MapNode($page);
181181 if ($nodes[$page]->parent_id == 0)
182182 $nodes[$page]->parent_id = $this->id;
183183 }
--- a/plugin/navi.inc.php
+++ b/plugin/navi.inc.php
@@ -102,12 +102,19 @@ function plugin_navi_convert()
102102 natcasesort($pages);
103103 if ($reverse) $pages = array_reverse($pages);
104104
105+ $pages = array_values($pages);
105106 $prev = $home;
106- foreach ($pages as $page) {
107- if ($page == $current) break;
107+ $next = '';
108+ foreach ($pages as $index => $page) {
109+ if ($page === $current) {
110+ $next_key = $index + 1;
111+ if (array_key_exists($next_key, $pages) {
112+ $next = $pages[$next_key];
113+ }
114+ break;
115+ }
108116 $prev = $page;
109117 }
110- $next = current($pages);
111118
112119 $pos = strrpos($current, '/');
113120 $up = '';
--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -91,7 +91,7 @@ function plugin_tracker_convert()
9191 }
9292 unset($args, $argc, $arg);
9393
94- $tracker_form = & new Tracker_form();
94+ $tracker_form = new Tracker_form();
9595 if (! $tracker_form->init($base, $refer, $config, $rel)) {
9696 return '#tracker: ' . htmlspecialchars($tracker_form->error) . '<br />';
9797 }
@@ -204,7 +204,7 @@ function plugin_tracker_action()
204204
205205 $from = $to = array();
206206
207- $tracker_form = & new Tracker_form();
207+ $tracker_form = new Tracker_form();
208208 if (! $tracker_form->init($base, $refer, $config)) {
209209 return array(
210210 'msg' => 'Cannot write',
@@ -437,7 +437,7 @@ class Tracker_form
437437 return FALSE;
438438 }
439439
440- $this->fields[$fieldname] = & new $class(
440+ $this->fields[$fieldname] = new $class(
441441 $this, // Reference
442442 array(
443443 $fieldname,
@@ -957,7 +957,7 @@ function plugin_tracker_list_render($base, $refer, $rel = '', $config = '', $ord
957957 $tracker_count++;
958958 //miko
959959
960- $tracker_list = & new Tracker_list();
960+ $tracker_list = new Tracker_list();
961961
962962 if (! $tracker_list->init($base, $refer, $config, $rel) ||
963963 ! $tracker_list->setSortOrder($order)) {
@@ -1017,7 +1017,7 @@ class Tracker_list
10171017
10181018 function init($base, $refer, $config = NULL, $relative = '')
10191019 {
1020- $this->form = & new Tracker_form();
1020+ $this->form = new Tracker_form();
10211021 return $this->form->init($base, $refer, $config, $relative);
10221022 }
10231023
--- a/skin/guiedit/wiki2xhtml.php
+++ b/skin/guiedit/wiki2xhtml.php
@@ -25,7 +25,7 @@ require_once(GUIEDIT_LIB_PATH . 'guiedit.ini.php');
2525 function guiedit_convert_html($lines) {
2626 if (! is_array($lines)) $lines = explode("\n", $lines);
2727
28- $body = & new BodyEx();
28+ $body = new BodyEx();
2929 $body->parse($lines);
3030
3131 return $body->toString();
@@ -517,7 +517,7 @@ class InlineEx extends ElementEx
517517
518518 function & toPara($class = '')
519519 {
520- $obj = & new ParagraphEx('', $class);
520+ $obj = new ParagraphEx('', $class);
521521 $obj->insert($this);
522522 return $obj;
523523 }
@@ -937,7 +937,7 @@ class TableEx extends ElementEx
937937 $is_template = ($this->type == 'c');
938938 $row = array();
939939 foreach ($cells as $cell)
940- $row[] = & new TableCellEx($cell, $is_template);
940+ $row[] = new TableCellEx($cell, $is_template);
941941 $this->elements[] = $row;
942942 }
943943