Media4um Posted September 26, 2022 Posted September 26, 2022 So I have been messing around with a McCodes script a bit, and I saw the function get_magic_quotes_gpc placed all through out the installer. I know that this is no longer supported as of PHP 7.4 and was completely removed at PHP 8.0. So I looked around the PHP manual and saw an entry about how to replace that function so that you won't encounter a bunch of Database Error pages along the way. You will have to redo the installation, as far as I know. Edit the installation page by editing the get_magic_quotes_gpc function and replacing it with the new function described here at the PHP Manual. https://www.php.net/manual/en/function.get-magic-quotes-gpc.php I recommend reading through this page at #4 which states: Here's what I came up with to remove magic quotes from request data. Replaces two single-quotes with one if magic_quotes_sybase are on, otherwise it just strips slashes. Note that the `foreach` style makes this work only with PHP 5 and above. <?php // Strip magic quotes from request data. if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { // Create lamba style unescaping function (for portability) $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)'; $stripslashes_deep = create_function('&$value, $fn', ' if (is_string($value)) { $value = ' . $unescape_function . '; } else if (is_array($value)) { foreach ($value as &$v) $fn($v, $fn); } '); // Unescape data $stripslashes_deep($_POST, $stripslashes_deep); $stripslashes_deep($_GET, $stripslashes_deep); $stripslashes_deep($_COOKIE, $stripslashes_deep); $stripslashes_deep($_REQUEST, $stripslashes_deep); } ?> As well as #12 which is the most upvoted response in the manual for this deprecated function: @ dot dot dot dot dot alexander at gmail dot com I suggest replacing foreach by "stripslashes_deep": Example #2 Using stripslashes() on an array on <http://www.php.net/manual/en/function.stripslashes.php>: <?php function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } ?> This gives: <?php if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off")) ){ stripslashes_deep($_GET); stripslashes_deep($_POST); stripslashes_deep($_COOKIE); } ?> This has helped me with working on my installer page, and I am currently running through the other files as well. Given that this script is dated and it was written at a time certain functions are now deprecated and completely removed, this script is somewhat redundant. But if you have a passion for the style of the game and a lack of skills to author an original code, you work with what you got. Any input about this would be appreciated. Any other techniques or references to other sources would be great! I hope this informed some of you McCodes users. Kind regards, Matt Quote
AlizHarb Posted September 26, 2022 Posted September 26, 2022 (edited) Yeah, it pissed me off once i tried to give a try for McCodes 🤪 I think first thing you have to do is making a template system for McCodes to make it easier for yourself, use smarty, twig or something like that Good luck Edited September 26, 2022 by AlizHarb Quote
Media4um Posted September 26, 2022 Author Posted September 26, 2022 (edited) Yeah it frustrated me too because I had to downgrade the PHP version to 7.4 just for the installer to work. So I am working on replacing this and making sure that you don't have to downgrade. I am not sure what smarty or twing is, could you be more specific? Or give me a reference link as to what it is? Thanks! Edited September 26, 2022 by Media4um Quote
AlizHarb Posted September 26, 2022 Posted September 26, 2022 https://www.smarty.net/ https://twig.symfony.com/ 1 Quote
peterisgb Posted September 27, 2022 Posted September 27, 2022 if (function_exists("get_magic_quotes_gpc") == false) { function get_magic_quotes_gpc() { return 0; } } if (get_magic_quotes_gpc() == 0) { foreach ($_POST as $k => $v) { $_POST[$k] = addslashes($v); } foreach ($_GET as $k => $v) { $_GET[$k] = addslashes($v); } } Myself. I just delete the whole lot. from the pages and carry on. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.