note 114157 added to security.magicquotes.disabling

From: Date: Fri, 17 Jan 2014 11:44:17 +0000
Subject: note 114157 added to security.magicquotes.disabling
Groups: php.notes 
Request: Send a blank email to php-notes+get-198267@lists.php.net to get a copy of this message
Here's a couple tips when using scripts on different (often shared) hosts, where ini_set doesn't work and php directives in .htaccess causes a 500 Internal Server Error. Firstly, copy the server's php.ini file to your domain's web-root folder. To find the correct paths, use phpinfo() and look for "Configuration File (php.ini) Path" and "DOCUMENT_ROOT" It's unlikely you'll have access to the php.ini via FTP, so instead run a script with a simple copy command (obviously inserting your paths): exec("cp /usr/local/php/etc/php.ini /home/LinuxPackage/public_html/php.ini); Edit the now-accessible php.ini file, and add settings like 'magic_quotes_gpc = off' at the bottom (regardless of whether they've been set earlier in the file). I also set: [PHP] max_execution_time = 60 max_input_time = 90 memory_limit = 64M post_max_size = 32M upload_max_filesize = 31M magic_quotes_gpc = Off Finally add the below line to your web-root htaccess file, to make the local php.ini the web-root default (so you don't need a copy in every script sub-folder): SetEnv PHPRC /home/LinuxPackage/public_html/php.ini Hope that helps a few people save some time! Mike. P.S. Using the new php_ini_loaded_file() function the whole lot could be done in three lines: exec("cp " . php_ini_loaded_file() . " " . $_SERVER['DOCUMENT_ROOT'] . "/php.ini"); fwrite(fopen("{$_SERVER['DOCUMENT_ROOT']}/php.ini", 'a'), PHP_EOL . '[PHP]' . PHP_EOL . "magic_quotes_gpc = Off" . PHP_EOL); fwrite(fopen("{$_SERVER['DOCUMENT_ROOT']}/.htaccess", 'a'), PHP_EOL . "SetEnv PHPRC {$_SERVER['DOCUMENT_ROOT']}/php.ini" . PHP_EOL); ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 (proxied: 195.191.86.49) ---- Manual Page -- http://php.net/manual/en/security.magicquotes.disabling.php Edit -- https://master.php.net/note/edit/114157 Del: integrated -- https://master.php.net/note/delete/114157/integrated Del: useless -- https://master.php.net/note/delete/114157/useless Del: bad code -- https://master.php.net/note/delete/114157/bad+code Del: spam -- https://master.php.net/note/delete/114157/spam Del: non-english -- https://master.php.net/note/delete/114157/non-english Del: in docs -- https://master.php.net/note/delete/114157/in+docs Del: other reasons-- https://master.php.net/note/delete/114157 Reject -- https://master.php.net/note/reject/114157 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198267) next »