Last active
July 6, 2019 15:35
-
-
Save mrgrain/9bf48c2eed106d237bb9cd605c64b66b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2eac0839aa98658cd33eb57565781ce5bc8a8eb0 Mon Sep 17 00:00:00 2001 | |
From: Moritz Kornher <[email protected]> | |
Date: Sat, 6 Jul 2019 14:49:39 +0100 | |
Subject: [PATCH] fix: stringparser issues, call by reference | |
--- | |
inc/functions.php | 4 +- | |
inc/stringparser.class.php | 4 +- | |
www/admin/admin_dlcat.php | 2 +- | |
www/admin/admin_dlnewcat.php | 2 +- | |
www/admin/admin_screencat.php | 2 +- | |
www/admin/admin_statspace.php | 2 +- | |
www/data/dlfile.php | 2 +- | |
www/data/download.php | 2 +- | |
www/libs/class_stringparser.php | 62 +++++++++++----------- | |
www/libs/class_stringparser_bbcode.php | 12 ++--- | |
10 files changed, 47 insertions(+), 47 deletions(-) | |
diff --git a/inc/functions.php b/inc/functions.php | |
index 474a93a..452f668 100644 | |
--- a/inc/functions.php | |
+++ b/inc/functions.php | |
@@ -41,7 +41,7 @@ function get_dl_categories (&$ids, $cat_id, $id=0, $ebene=-1) | |
{ | |
$zeile[ebene] = $ebene + 1; | |
$ids[] = $zeile; | |
- get_dl_categories (&$ids, $cat_id, $zeile[cat_id], $zeile[ebene]); | |
+ get_dl_categories ($ids, $cat_id, $zeile[cat_id], $zeile[ebene]); | |
} | |
} | |
} | |
@@ -61,7 +61,7 @@ function get_script_categories (&$ids, $cat_id, $id=0, $ebene=-1) | |
{ | |
$zeile[ebene] = $ebene + 1; | |
$ids[] = $zeile; | |
- get_script_categories (&$ids, $cat_id, $zeile[cat_id], $zeile[ebene]); | |
+ get_script_categories ($ids, $cat_id, $zeile[cat_id], $zeile[ebene]); | |
} | |
} | |
} | |
diff --git a/inc/stringparser.class.php b/inc/stringparser.class.php | |
index 0a6b7b3..3dfe793 100644 | |
--- a/inc/stringparser.class.php | |
+++ b/inc/stringparser.class.php | |
@@ -284,7 +284,7 @@ class StringParser { | |
StringParser_Node::destroyNode ($this->_root); | |
} | |
unset ($this->_root); | |
- $this->_root =& new StringParser_Node_Root (); | |
+ $this->_root = new StringParser_Node_Root (); | |
$this->_stack[0] =& $this->_root; | |
$this->_parserInit (); | |
@@ -1250,7 +1250,7 @@ class StringParser_Node { | |
* @param object $node The node to destroy | |
* @return bool True on success, else false. | |
*/ | |
- function destroyNode (&$node) { | |
+ static function destroyNode (&$node) { | |
if ($node === null) { | |
return false; | |
} | |
diff --git a/www/admin/admin_dlcat.php b/www/admin/admin_dlcat.php | |
index 715d8a4..4b27639 100644 | |
--- a/www/admin/admin_dlcat.php | |
+++ b/www/admin/admin_dlcat.php | |
@@ -35,7 +35,7 @@ elseif (isset($_POST[editcatid])) | |
settype ($_POST[editcatid], 'integer'); | |
$valid_ids = array(); | |
- get_dl_categories (&$valid_ids, $_POST[editcatid]); | |
+ get_dl_categories ($valid_ids, $_POST[editcatid]); | |
$index = mysql_query("SELECT * FROM ".$global_config_arr[pref]."dl_cat WHERE cat_id = '$_POST[editcatid]'", $db); | |
$cat_arr = mysql_fetch_assoc($index); | |
diff --git a/www/admin/admin_dlnewcat.php b/www/admin/admin_dlnewcat.php | |
index 854c940..37bb715 100644 | |
--- a/www/admin/admin_dlnewcat.php | |
+++ b/www/admin/admin_dlnewcat.php | |
@@ -46,7 +46,7 @@ else | |
'; | |
$valid_ids = array(); | |
- get_dl_categories (&$valid_ids, -1); | |
+ get_dl_categories ($valid_ids, -1); | |
foreach ($valid_ids as $cat) | |
{ | |
diff --git a/www/admin/admin_screencat.php b/www/admin/admin_screencat.php | |
index af5ac99..4738b71 100644 | |
--- a/www/admin/admin_screencat.php | |
+++ b/www/admin/admin_screencat.php | |
@@ -9,7 +9,7 @@ if ($_POST['cat_id'] && $_POST['cat_name'] && $_POST['sended'] == "edit") | |
$_POST[cat_name] = savesql($_POST[cat_name]); | |
$_POST['cat_id'] = intval($_POST['cat_id']); | |
$_POST['cat_type'] = intval($_POST['cat_type']); | |
- $_POST['cat_visibility'] = intval($_POST['cat_visibility']) | |
+ $_POST['cat_visibility'] = intval($_POST['cat_visibility']); | |
mysql_query("UPDATE ".$global_config_arr[pref]."screen_cat | |
SET cat_name = '$_POST[cat_name]', | |
diff --git a/www/admin/admin_statspace.php b/www/admin/admin_statspace.php | |
index 0407e5f..bcea24c 100644 | |
--- a/www/admin/admin_statspace.php | |
+++ b/www/admin/admin_statspace.php | |
@@ -92,7 +92,7 @@ function list_dir (&$files, $dirname, $dirs=NULL, $ebene=-1) | |
$files[] = $datei; | |
if (@in_array($file, $dirs) || !$dirs) | |
{ | |
- $size += list_dir (&$files, $dirname . '/' . $file, $dirs, $datei[ebene]); | |
+ $size += list_dir ($files, $dirname . '/' . $file, $dirs, $datei[ebene]); | |
} | |
} | |
else | |
diff --git a/www/data/dlfile.php b/www/data/dlfile.php | |
index 0ff0aa8..312a108 100644 | |
--- a/www/data/dlfile.php | |
+++ b/www/data/dlfile.php | |
@@ -167,7 +167,7 @@ if (mysql_num_rows($index) > 0) | |
// Navigation erzeugen | |
$valid_ids = array(); | |
- get_dl_categories (&$valid_ids, $dl_arr['cat_id'], $config_arr['dl_show_sub_cats'] ); | |
+ get_dl_categories ($valid_ids, $dl_arr['cat_id'], $config_arr['dl_show_sub_cats'] ); | |
foreach ( $valid_ids as $cat ) { | |
if ($cat['cat_id'] == $dl_arr['cat_id']) { | |
diff --git a/www/data/download.php b/www/data/download.php | |
index 937ee43..882e11c 100644 | |
--- a/www/data/download.php | |
+++ b/www/data/download.php | |
@@ -46,7 +46,7 @@ if (isset($_GET['keyword']) && $_GET['keyword'] != "") | |
///////////////////////////// | |
$valid_ids = array(); | |
-get_dl_categories (&$valid_ids, $_GET['cat_id'], $config_arr['dl_show_sub_cats'] ); | |
+get_dl_categories ($valid_ids, $_GET['cat_id'], $config_arr['dl_show_sub_cats'] ); | |
foreach ($valid_ids as $cat) { | |
$cat['cat_name'] = stripslashes ( $cat['cat_name'] ); | |
diff --git a/www/libs/class_stringparser.php b/www/libs/class_stringparser.php | |
index 3f48ffa..f137e44 100755 | |
--- a/www/libs/class_stringparser.php | |
+++ b/www/libs/class_stringparser.php | |
@@ -282,8 +282,8 @@ class StringParser { | |
StringParser_Node::destroyNode ($this->_root); | |
} | |
unset ($this->_root); | |
- $this->_root =& new StringParser_Node_Root (); | |
- $this->_stack[0] =& $this->_root; | |
+ $this->_root = new StringParser_Node_Root (); | |
+ $this->_stack[0] = $this->_root; | |
$this->_parserInit (); | |
@@ -342,7 +342,7 @@ class StringParser { | |
} | |
if (is_null ($this->_output)) { | |
- $root =& $this->_root; | |
+ $root = $this->_root; | |
unset ($this->_root); | |
$this->_root = null; | |
while (count ($this->_stack)) { | |
@@ -438,9 +438,9 @@ class StringParser { | |
if (($stack_count = count ($this->_stack)) < 2) { | |
return false; | |
} | |
- $topelem =& $this->_stack[$stack_count-1]; | |
+ $topelem = $this->_stack[$stack_count-1]; | |
- $node_parent =& $topelem->_parent; | |
+ $node_parent = $topelem->_parent; | |
// remove the child from the tree | |
$res = $node_parent->removeChild ($topelem, false); | |
if (!$res) { | |
@@ -746,11 +746,11 @@ class StringParser { | |
*/ | |
function _pushNode (&$node) { | |
$stack_count = count ($this->_stack); | |
- $max_node =& $this->_stack[$stack_count-1]; | |
+ $max_node = $this->_stack[$stack_count-1]; | |
if (!$max_node->appendChild ($node)) { | |
return false; | |
} | |
- $this->_stack[$stack_count] =& $node; | |
+ $this->_stack[$stack_count] = $node; | |
return true; | |
} | |
@@ -947,7 +947,7 @@ class StringParser_Node { | |
// if node already has a parent | |
if ($node->_parent !== false) { | |
// remove node from there | |
- $parent =& $node->_parent; | |
+ $parent = $node->_parent; | |
if (!$parent->removeChild ($node, false)) { | |
return false; | |
} | |
@@ -958,15 +958,15 @@ class StringParser_Node { | |
// move all nodes to a new index | |
while ($index >= 0) { | |
// save object | |
- $object =& $this->_children[$index]; | |
+ $object = $this->_children[$index]; | |
// we have to unset it because else it will be | |
// overridden in in the loop | |
unset ($this->_children[$index]); | |
// put object to new position | |
- $this->_children[$index+1] =& $object; | |
+ $this->_children[$index+1] = $object; | |
$index--; | |
} | |
- $this->_children[0] =& $node; | |
+ $this->_children[0] = $node; | |
return true; | |
} | |
@@ -979,7 +979,7 @@ class StringParser_Node { | |
function appendToLastTextChild ($text) { | |
$ccount = count ($this->_children); | |
if ($ccount == 0 || $this->_children[$ccount-1]->_type != STRINGPARSER_NODE_TEXT) { | |
- $ntextnode =& new StringParser_Node_Text ($text); | |
+ $ntextnode = new StringParser_Node_Text ($text); | |
return $this->appendChild ($ntextnode); | |
} else { | |
$this->_children[$ccount-1]->appendText ($text); | |
@@ -1011,7 +1011,7 @@ class StringParser_Node { | |
// if node already has a parent | |
if ($node->_parent !== null) { | |
// remove node from there | |
- $parent =& $node->_parent; | |
+ $parent = $node->_parent; | |
if (!$parent->removeChild ($node, false)) { | |
return false; | |
} | |
@@ -1020,8 +1020,8 @@ class StringParser_Node { | |
// append it to current node | |
$new_index = count ($this->_children); | |
- $this->_children[$new_index] =& $node; | |
- $node->_parent =& $this; | |
+ $this->_children[$new_index] = $node; | |
+ $node->_parent = $this; | |
return true; | |
} | |
@@ -1054,7 +1054,7 @@ class StringParser_Node { | |
// if node already has a parent | |
if ($node->_parent !== null) { | |
// remove node from there | |
- $parent =& $node->_parent; | |
+ $parent = $node->_parent; | |
if (!$parent->removeChild ($node, false)) { | |
return false; | |
} | |
@@ -1065,15 +1065,15 @@ class StringParser_Node { | |
// move all nodes to a new index | |
while ($index >= $child) { | |
// save object | |
- $object =& $this->_children[$index]; | |
+ $object = $this->_children[$index]; | |
// we have to unset it because else it will be | |
// overridden in in the loop | |
unset ($this->_children[$index]); | |
// put object to new position | |
- $this->_children[$index+1] =& $object; | |
+ $this->_children[$index+1] = $object; | |
$index--; | |
} | |
- $this->_children[$child] =& $node; | |
+ $this->_children[$child] = $node; | |
return true; | |
} | |
@@ -1106,7 +1106,7 @@ class StringParser_Node { | |
// if node already has a parent | |
if ($node->_parent !== false) { | |
// remove node from there | |
- $parent =& $node->_parent; | |
+ $parent = $node->_parent; | |
if (!$parent->removeChild ($node, false)) { | |
return false; | |
} | |
@@ -1117,15 +1117,15 @@ class StringParser_Node { | |
// move all nodes to a new index | |
while ($index >= $child + 1) { | |
// save object | |
- $object =& $this->_children[$index]; | |
+ $object = $this->_children[$index]; | |
// we have to unset it because else it will be | |
// overridden in in the loop | |
unset ($this->_children[$index]); | |
// put object to new position | |
- $this->_children[$index+1] =& $object; | |
+ $this->_children[$index+1] = $object; | |
$index--; | |
} | |
- $this->_children[$child + 1] =& $node; | |
+ $this->_children[$child + 1] = $node; | |
return true; | |
} | |
@@ -1147,7 +1147,7 @@ class StringParser_Node { | |
function removeChild (&$child, $destroy = false) { | |
if (is_object ($child)) { | |
// if object: get index | |
- $object =& $child; | |
+ $object = $child; | |
unset ($child); | |
$child = $this->_findChild ($object); | |
if ($child === false) { | |
@@ -1163,7 +1163,7 @@ class StringParser_Node { | |
if (!isset($this->_children[$child])) { | |
return false; | |
} | |
- $object =& $this->_children[$child]; | |
+ $object = $this->_children[$child]; | |
} | |
// store count for later use | |
@@ -1193,12 +1193,12 @@ class StringParser_Node { | |
// move all remaining objects one index higher | |
while ($child < $ccount - 1) { | |
// save object | |
- $obj =& $this->_children[$child+1]; | |
+ $obj = $this->_children[$child+1]; | |
// we have to unset it because else it will be | |
// overridden in in the loop | |
unset ($this->_children[$child+1]); | |
// put object to new position | |
- $this->_children[$child] =& $obj; | |
+ $this->_children[$child] = $obj; | |
// UNSET THE OBJECT! | |
unset ($obj); | |
$child++; | |
@@ -1248,13 +1248,13 @@ class StringParser_Node { | |
* @param object $node The node to destroy | |
* @return bool True on success, else false. | |
*/ | |
- function destroyNode (&$node) { | |
+ static function destroyNode (&$node) { | |
if ($node === null) { | |
return false; | |
} | |
// if parent exists: remove node from tree! | |
if ($node->_parent !== null) { | |
- $parent =& $node->_parent; | |
+ $parent = $node->_parent; | |
// directly return that result because the removeChild | |
// method will call destroyNode again | |
return $parent->removeChild ($node, true); | |
@@ -1357,13 +1357,13 @@ class StringParser_Node { | |
$node_ctr = 0; | |
for ($i = 0; $i < count ($this->_children); $i++) { | |
if ($this->_children[$i]->matchesCriterium ($criterium, $value)) { | |
- $nodes[$node_ctr++] =& $this->_children[$i]; | |
+ $nodes[$node_ctr++] = $this->_children[$i]; | |
} | |
$subnodes = $this->_children[$i]->getNodesByCriterium ($criterium, $value); | |
if (count ($subnodes)) { | |
$subnodes_count = count ($subnodes); | |
for ($j = 0; $j < $subnodes_count; $j++) { | |
- $nodes[$node_ctr++] =& $subnodes[$j]; | |
+ $nodes[$node_ctr++] = $subnodes[$j]; | |
unset ($subnodes[$j]); | |
} | |
} | |
diff --git a/www/libs/class_stringparser_bbcode.php b/www/libs/class_stringparser_bbcode.php | |
index 3feebda..36d4229 100755 | |
--- a/www/libs/class_stringparser_bbcode.php | |
+++ b/www/libs/class_stringparser_bbcode.php | |
@@ -564,7 +564,7 @@ class StringParser_BBCode extends StringParser { | |
return true; | |
} | |
if ($needle == '[') { | |
- $node =& new StringParser_BBCode_Node_Element ($this->_cpos); | |
+ $node = new StringParser_BBCode_Node_Element ($this->_cpos); | |
$res = $this->_pushNode ($node); | |
if (!$res) { | |
return false; | |
@@ -1207,7 +1207,7 @@ class StringParser_BBCode extends StringParser { | |
for ($i = 0; $i < count ($sub_nodes); $i++) { | |
if (!$last_node_was_paragraph || ($prevtype == $sub_nodes[$i]->_type && ($i != 0 || $prevtype != STRINGPARSER_BBCODE_NODE_ELEMENT))) { | |
unset ($paragraph); | |
- $paragraph =& new StringParser_BBCode_Node_Paragraph (); | |
+ $paragraph = new StringParser_BBCode_Node_Paragraph (); | |
} | |
$prevtype = $sub_nodes[$i]->_type; | |
if ($sub_nodes[$i]->_type != STRINGPARSER_BBCODE_NODE_ELEMENT || $sub_nodes[$i]->getFlag ('paragraph_type', 'integer', BBCODE_PARAGRAPH_ALLOW_BREAKUP) != BBCODE_PARAGRAPH_BLOCK_ELEMENT) { | |
@@ -1218,7 +1218,7 @@ class StringParser_BBCode extends StringParser { | |
$dest_nodes[] =& $sub_nodes[$i]; | |
$last_onde_was_paragraph = false; | |
unset ($paragraph); | |
- $paragraph =& new StringParser_BBCode_Node_Paragraph (); | |
+ $paragraph = new StringParser_BBCode_Node_Paragraph (); | |
} | |
} | |
} | |
@@ -1261,7 +1261,7 @@ class StringParser_BBCode extends StringParser { | |
if ($node->_type == STRINGPARSER_NODE_TEXT) { | |
$cpos = 0; | |
while (($npos = strpos ($node->content, $detect_string, $cpos)) !== false) { | |
- $subnode =& new StringParser_Node_Text (substr ($node->content, $cpos, $npos - $cpos), $node->occurredAt + $cpos); | |
+ $subnode = new StringParser_Node_Text (substr ($node->content, $cpos, $npos - $cpos), $node->occurredAt + $cpos); | |
// copy flags | |
foreach ($node->_flags as $flag => $value) { | |
if ($flag == 'newlinemode.begin') { | |
@@ -1278,7 +1278,7 @@ class StringParser_BBCode extends StringParser { | |
unset ($subnode); | |
$cpos = $npos + strlen ($detect_string); | |
} | |
- $subnode =& new StringParser_Node_Text (substr ($node->content, $cpos), $node->occurredAt + $cpos); | |
+ $subnode = new StringParser_Node_Text (substr ($node->content, $cpos), $node->occurredAt + $cpos); | |
if ($cpos == 0) { | |
$value = $node->getFlag ('newlinemode.begin', 'integer', null); | |
if ($value !== null) { | |
@@ -1532,7 +1532,7 @@ class StringParser_BBCode_Node_Element extends StringParser_Node { | |
* @return object | |
*/ | |
function &duplicate () { | |
- $newnode =& new StringParser_BBCode_Node_Element ($this->occurredAt); | |
+ $newnode = new StringParser_BBCode_Node_Element ($this->occurredAt); | |
$newnode->_name = $this->_name; | |
$newnode->_flags = $this->_flags; | |
$newnode->_attributes = $this->_attributes; | |
-- | |
2.20.1 | |
From 60de0ceee24edb3b5a5cdf423a9db04d15c7f7f3 Mon Sep 17 00:00:00 2001 | |
From: Moritz Kornher <[email protected]> | |
Date: Sat, 6 Jul 2019 16:31:58 +0100 | |
Subject: [PATCH] fix: remove magic quotes | |
--- | |
www/admin/admin_articles_prev.php | 2 -- | |
www/admin/admin_find_applet.php | 3 --- | |
www/admin/admin_find_file.php | 3 --- | |
www/admin/admin_news_prev.php | 3 --- | |
www/admin/index.php | 3 --- | |
www/imageviewer.php | 2 -- | |
www/includes/functions.php | 3 --- | |
www/index.php | 3 --- | |
8 files changed, 22 deletions(-) | |
diff --git a/www/admin/admin_articles_prev.php b/www/admin/admin_articles_prev.php | |
index 87b1274..ac3b176 100644 | |
--- a/www/admin/admin_articles_prev.php | |
+++ b/www/admin/admin_articles_prev.php | |
@@ -1,8 +1,6 @@ | |
<?php | |
// Start Session | |
session_start(); | |
-// Disable magic_quotes_runtime | |
-set_magic_quotes_runtime ( FALSE ); | |
// fs2 include path | |
set_include_path ( '.' ); | |
diff --git a/www/admin/admin_find_applet.php b/www/admin/admin_find_applet.php | |
index 6e1e748..d5bf837 100644 | |
--- a/www/admin/admin_find_applet.php | |
+++ b/www/admin/admin_find_applet.php | |
@@ -2,9 +2,6 @@ | |
// Start Session | |
session_start(); | |
-// Disable magic_quotes_runtime | |
-set_magic_quotes_runtime ( FALSE ); | |
- | |
// fs2 include path | |
set_include_path ( '.' ); | |
define ( FS2_ROOT_PATH, "./../", TRUE ); | |
diff --git a/www/admin/admin_find_file.php b/www/admin/admin_find_file.php | |
index c350bbc..0107e2c 100644 | |
--- a/www/admin/admin_find_file.php | |
+++ b/www/admin/admin_find_file.php | |
@@ -2,9 +2,6 @@ | |
// Start Session | |
session_start(); | |
-// Disable magic_quotes_runtime | |
-set_magic_quotes_runtime ( FALSE ); | |
- | |
// fs2 include path | |
set_include_path ( '.' ); | |
define ( FS2_ROOT_PATH, "./../", TRUE ); | |
diff --git a/www/admin/admin_news_prev.php b/www/admin/admin_news_prev.php | |
index 6c2d698..f5ccc29 100644 | |
--- a/www/admin/admin_news_prev.php | |
+++ b/www/admin/admin_news_prev.php | |
@@ -2,9 +2,6 @@ | |
// Start Session | |
session_start(); | |
-// Disable magic_quotes_runtime | |
-set_magic_quotes_runtime(FALSE); | |
- | |
// fs2 include path | |
set_include_path('.'); | |
define('FS2_ROOT_PATH', "./../", TRUE); | |
diff --git a/www/admin/index.php b/www/admin/index.php | |
index 580b66f..59858af 100644 | |
--- a/www/admin/index.php | |
+++ b/www/admin/index.php | |
@@ -2,9 +2,6 @@ | |
// Start Session | |
session_start (); | |
-// Disable magic_quotes_runtime | |
-ini_set('magic_quotes_runtime', 0); | |
- | |
// fs2 include path | |
set_include_path ( '.' ); | |
define ( 'FS2_ROOT_PATH', "./../", TRUE ); | |
diff --git a/www/imageviewer.php b/www/imageviewer.php | |
index b5d67b0..6c96f2c 100644 | |
--- a/www/imageviewer.php | |
+++ b/www/imageviewer.php | |
@@ -1,8 +1,6 @@ | |
<?php | |
// Start Session | |
session_start (); | |
-// Disable magic_quotes_runtime | |
-set_magic_quotes_runtime ( FALSE ); | |
// fs2 include path | |
set_include_path ( '.' ); | |
diff --git a/www/includes/functions.php b/www/includes/functions.php | |
index d40945e..26c62d5 100755 | |
--- a/www/includes/functions.php | |
+++ b/www/includes/functions.php | |
@@ -1195,9 +1195,6 @@ function savesql ( $TEXT ) | |
function unquote ( $TEXT ) | |
{ | |
- if ( get_magic_quotes_gpc () ) { | |
- $TEXT = stripslashes ( $TEXT ); | |
- } | |
return $TEXT; | |
} | |
diff --git a/www/index.php b/www/index.php | |
index 00d0b92..7505c03 100644 | |
--- a/www/index.php | |
+++ b/www/index.php | |
@@ -2,9 +2,6 @@ | |
// Start Session | |
session_start (); | |
-// Disable magic_quotes_runtime | |
-ini_set('magic_quotes_runtime', 0); | |
- | |
// fs2 include path | |
set_include_path ( '.' ); | |
define ( 'FS2_ROOT_PATH', "./", TRUE ); | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment