- Joomla 3.0 и magic_quotes_gpc
- О волшебных кавычках
- Волшебные кавычки и Joomla
- Проблема
- Решение проблемы
- Отключение magic_quotes_gpc в Joomla 3 (волшебные кавычки)
- Способ №1: Отключение волшебных кавычек с помощью php.ini
- Способ №2: Отключение волшебных кавычек с помощью .htaccess
- Joomla magic quotes gpc off
- magic_quotes_gpc и joomla
- Отключение magic_quotes_gpc
- Способ первый. через .htaccess
- Способ второй. php.ini
- Способ третий. Хардкод
- How to turn off magic quotes gpc
- Материал из Joomla! Documentation
- Содержание
- For MAMP [ править ]
- For Most Mainstream Hosting Companies Running a CGI-Webinterface [ править ]
- .htaccess for Some Hosts [ править ]
- Yet Another Solution For Shared Hosts [ править ]
- The Joomla! Forum™
- Magic Quotes GPC Off ?
- Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- Re: Magic Quotes GPC Off ?
- a workaround Magic Quotes and Joomla 3.0
Joomla 3.0 и magic_quotes_gpc
О волшебных кавычках
Наверное, многие уже знают о том, что волшебные кавычки (magic quotes) были объявлены устаревшими в PHP 5.3 и полностью удалены в PHP 5.4. Для тех, кто не знает всей истории волшебных кавычек, милости просим прочитать официальный мануал на эту тему:
Волшебные кавычки и Joomla
В качестве рекомендации до версии 3.0 значение настройки magic_quotes_gpc должно было быть «выключено». Так как это был уровень рекомендации, а не требования, класс JRequest делал проверку этого значения, и если оно было включено, он удалял лишние кавычки с помощью функции stripslashes .
С выходом Joomla 3.0 все меняется. Класса JRequest больше нет, так как его заменил класс JInput, в котором нет этой проверки. Впрочем, в этом нет никакой необходимости, так как требования Joomla 3.0 – PHP не ниже версии 5.3.1, и как я уже упоминал ранее, волшебные кавычки были объявлены устаревшими в PHP 5.3. Действительно, зачем тратить ресурс на проверку того, что скоро будет удалено?
Проблема
После некоторых обсуждений в группах Google, было принято решение не городить огород и не пытаться обойти требование Joomla Platform 12 (на которой базируется Joomla 3.0) о выключенных волшебных кавычках. Но что это значит для простого пользователя, который захочет установить Joomla 3.0? А это значит, что при установке нельзя пройти даже первый шаг. Вместо него будет отображаться окно минимальных требований:
Но что же делать, ведь многие хостеры форсируют настройку magic_quotes_gpc во «включено»?
Решение проблемы
Итак, при установке Joomla 3.0 вы столкнулись с тем, что волшебные кавычки включены. Как же их отключить? Есть три пути решения этой проблемы:
1. Файл .htaccess.
Самый простой способ. Но он поможет только тогда, когда PHP работает на сервере как модуль Apache. Если PHP работает как FCGI, то переходите к пункту 2, в противном случае этот способ приведет к ошибке 500. Итак, просто добавьте в файл .htaccess следующую строку:
Отключение magic_quotes_gpc в Joomla 3 (волшебные кавычки)
Часто встречается ситуация, когда при установке или уже непосредственно при работе с Joomla 3 появляется ошибка «magic_quotes_gpc».
Для стабильной работы Joomla 3, директиву «magic_quotes_gpc» необходимо отключить в настройках хостинга.
Как показывает практика, сделать это довольно просто.
magic_quotes_gpc — опция в PHP. При активированной опции, к символам: ‘ (одинарные кавычки), » (двойные кавычки) и (обратный слэш) в POST, GET и COOKIE переменных, автоматически добавляется обратный слэш. Данная опция перешла в разряд устаревших (deprecated), после версии php 5.3.
Способ №1:
Отключение волшебных кавычек с помощью php.ini
Отредактировать файл php.ini, дописыванием или редактируем строчку:
На многих хостингах, доступ к файлу php.ini ограничен и возможность внести в него изменения у вас не будет, тогда возможно вам поможет способ №2.
Способ №2:
Отключение волшебных кавычек с помощью .htaccess
Только если php работает как модуль Apache, что как правило на большинстве хостингов, в файле .htaccess дописыванием или редактируем строчку:
php_flag magic_quotes_gpc Off
Вдруг случилось так, что не один из способов не помог устранить проблему, тогда необходимо написать в техническую поддержку хостинга, рассказать суть проблемы и попросить отключить директиву magic_quotes_gpc.
Всем удачи!
Возможно вам так же будет интересно:
Если я Вам помог — оставьте свой отзыв или поделитесь сайтом с друзьями в социальных сетях!
Joomla magic quotes gpc off
magic quotes gpc — опция php, которая включает предварительную обработку -экранирование спецсимволов внутри данных get- и post- запросов. Задумка была такова, что забывчивые программисты могли оставить sql-инъекцию на сайте, а если все данные изначально экранируются, то забыть их разъэкранировать гораздо сложнее, чем наоборот.
Вскоре разработчики пришли к выводу, что такой подход не удобен, но хитрые хостеры предпочитают по умолчанию все-таки включать её, по понятным причинам, и не всегда дают возможность ее убрать.
После версии PHP 5.3 данная опция перешла в разряд deprecated(устаревшая), а вскоре и вовсе будет выпилена из php.
magic_quotes_gpc и joomla
А в Joomla до 3-ьей версии magic_quotes_gpc проверялась внутри самого фрэймворка и автоматически предпринималось разэкранирование, в случае, если она была включена. В Joomla 3 эту самую проверку убрали и вместо этого добавили требование версии php > 5.3 при установке. По мне сомнительное решение. Но нытьем проблему не решить, поэтому начинаем делать.
Отключение magic_quotes_gpc
Способ первый. через .htaccess
Работает в тех случаях, когда хостер позволяет через .htaccess управлять конфигурацией php.
Дописываем в htaccess файл строчку:
php_flag magic_quotes_gpc off
Способ второй. php.ini
Самый правильный способ, но на shared-хостингах как правило не подпускают к настройкам php. Зачастую доступ к php.ini дается через панель хостинга. В остальных случаях, всё просто:
Открываем php.ini, дописываем или редактируем строчку
Способ третий. Хардкод
добавляем эти строки в начало файлов index.php и administrator/index.php
Просто проходимся по массивам входных данных и убираем лишнее. Этот поможет в случае, если необходимо перенести готовый сайт на хостинг, где эта опция включена и это навсегда. Так и случилось со мной, один из моих сайтов на joomla расположился на godaddy, где по умолчанию magic_quotes_gpc включено, а возможности отключить нет.
How to turn off magic quotes gpc
Материал из Joomla! Documentation
Magic Quotes was a feature deprecated in PHP 5.3 and removed in Joomla 5.4 and higher. This documentation page is only relevant for Joomla 3 users still running PHP 5.3
Содержание
For MAMP [ править ]
- Go to MAMP application >> Preferences (button) >> PHP (tab) >> Choose 5.3.1 or greater >> choose OK.
- Go to the MAMP folder >> bin >> php >> php5.3.26 >> conf >> edit php.ini >> add «magic_quotes_gpc = Off» a few lines above «magic_quotes_sybase = Off».
- Restart MAMP’s servers.
For Most Mainstream Hosting Companies Running a CGI-Webinterface [ править ]
- Create a php.ini or php5.ini file with the following:
- Put it in your Joomla 3 root. Then change the htaccess.txt in your Joomla 3 root to .htaccess. Add the following lines to the .htaccess file (at the top), don’t forget to change php.ini to php5.ini when applicable :
Change «myusername» and «yourJ3folder» to your respective folders. The «/home/myusername/public_html/yourJ3folder» can be found via the Global Configuration:
In Joomla Backend > System > System Information > [Directory Permissions], the folder is usually the same as the log directory (but without /logs at the end).
.htaccess for Some Hosts [ править ]
For some hosts, add the following to the .htaccess file in the root of your site (for example /home/myusername/public_html/.htaccess)
Yet Another Solution For Shared Hosts [ править ]
- create a php.ini file at your Joomla! root.
- Add this content to the file and save
- Edit your .htaccess file and add this line at the top and save the file
SetEnv PHPRC /home/youruser/public_html/php.ini
- Test if the error message goes away
The Joomla! Forum™
Magic Quotes GPC Off ?
Magic Quotes GPC Off ?
Post by duanemitchell » Mon Oct 01, 2012 3:47 am
Can’t install without turning magic quotes off in 3.0. I’ve searched around for a solution and tried a couple without success.
I created a php.ini file in the public_html with the line «magic_quotes_gpc=off», that didn’t work.
Gonna open a ticket with Namecheap and see what they say.
I’d be happy to hear any suggestions.
Re: Magic Quotes GPC Off ?
Post by silicon_chip » Mon Oct 01, 2012 10:13 am
You my friend might just be in luck , since I just spent 4 hours getting this fixed myself.
I had the Magic Quotes GPC ON and when I fixed THAT problem, I was getting install permission problems.
This was my fix, hope it helps you .
Create php.ini file with the following lines.
magic_quotes_gpc = Off
session.save_path = «/tmp»
Copy to the Installation subfolder of your site.
Let me know if it fixes your problem.
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Mon Oct 01, 2012 12:18 pm
Re: Magic Quotes GPC Off ?
Post by gbraanker » Mon Oct 01, 2012 2:25 pm
Didn’t work for me.
anything else I could do?
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Mon Oct 01, 2012 2:53 pm
The only thing I can think of to do is open a ticket with your host and have them do it for you.
AFAIK, the only way to do this is to modify the php configuration through the use of a php.ini file. Some hosts give you access to this, some don’t. Where you don’t have access you have to create the file as described above and put it into the «Installation» folder.
I tried creating one at the top level of my public_html and that didn’t work. It should have though it seems to me. I opened a ticket with Namecheap and they told me that is what to do but I had already used the above solution. I’m wondering if there is a cache issue of some sort?
Re: Magic Quotes GPC Off ?
Post by alikon » Mon Oct 01, 2012 6:42 pm
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Mon Oct 01, 2012 9:15 pm
in the .htaccess. I didn’t include the «php_flag» part.
Discussion on the subject of turning magic quotes off does not seem to settle on one solution. It seems that the way php is config’d on the host server and what one can do to change that varies widely. It seems the trick is to find a thread that works for you.
What’s new with the 3.0 install is that the first thing it does is check your settings and if magic quotes is on then it stops right there until it’s fixed.
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Tue Oct 02, 2012 12:56 am
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Tue Oct 02, 2012 1:32 am
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Tue Oct 02, 2012 1:52 am
I’m having issues with image paths getting escaped when they shouldn’t as in this thread I posted:
I have a MAMP install of Joomla 3.0 where magic quotes is off and I don’t have this problem.
Re: Magic Quotes GPC Off ?
Post by silicon_chip » Tue Oct 02, 2012 4:01 am
You may have to get your host to set the Magic Quotes option to OFF
Alternatively try placing a php.ini file in each of your sub directories and see if that can fix your issue.
Not sure it will work, but might be worth a try in the short term.
Re: Magic Quotes GPC Off ?
Post by duanemitchell » Tue Oct 02, 2012 4:02 pm
where username is my cPanel login username.
This was AFTER I used the cPanel tool «Tweak php.ini». That created a full featured php.ini file at the top level of public_html. That had magic quotes on, I set them to off. Then the above .htaccess addition worked to apply that php.ini config to the entire directory.
So I guess, for me on Namecheap as a host, my Joomla 3.0 install procedure would be to create the php.ini with magic_quote_gpc off and then add the above line to .htaccess.
If that doesn’t work then I’ll use the trick mentioned above of adding the 2 line php.ini to the installation folder, run the installation, then do the above 2 steps.
Re: Magic Quotes GPC Off ?
Post by humvee » Wed Oct 03, 2012 11:08 am
[Mod note: Glad you managed to resolve it for yourself. Thank you for providing your solution to this issue for others to see.
Marked Resolved]
When you create a local php.ini as originally indicated and added it to the joomla_root/ directory you must also add a copy to the joomla_root/administrator/ directory too, that way both the site index.php and the administrator index.php are working from the same song sheet!
Re: Magic Quotes GPC Off ?
Post by acim68 » Thu Oct 04, 2012 4:45 pm
Yes. It works nice to turn off magic Quotes. in my case there is a Installatron Aplication Installer that install the last version of several programs.
But the magic Quotes where On, and then I had the version install but with the problems. I did put the php.ini in Administrator folder. Work fine.
Thanks a lot for your tips….
Re: Magic Quotes GPC Off ?
Post by acim68 » Fri Oct 05, 2012 2:08 pm
Re: Magic Quotes GPC Off ?
Post by silicon_chip » Sat Oct 06, 2012 12:21 am
An addendum to my original solution to getting Joomla 3.0 to install.
The following is a multiple step solution to
1. Install
2. Turn Magic Quotes off
Step 1.
Copy your Joomla 3.0 folders to your webhost
Create a php.ini file with the following lines:
magic_quotes_gpc = Off
session.save_path = «/tmp»
Copy the php.ini file to your /installation subfolder on your webhost.
(You may or may not need the session.save_path line and you might need to edit it for the specific location of the /tmp folder on your webhost)
Now you should be able to go to your browser , open your website and have Joomla think magic quotes is off. (It isn’t really, but this will let you install at least.)
Proceed with your install.
Step2.
Go to the root folder of your website and create a php.ini file
Add the following lines:
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
Next we need to edit/create a .htaccess file in the root directory
it should have the following line:
SetEnv PHPRC /path /to/php.ini
The path will vary depending on your webhost
For example on my own site it is set as follows:
«SetEnv PHPRC /home/username/public_html/php.ini» where the username is my cpanel username.
Now for the usual problems.
If you create a php.ini file or a .htaccess file in some editors, be aware they may add an extension to the filename.
Make sure php.ini ISN’T really php.ini.txt for example.
And don’t forget the «.» in front of the .htaccess
I hope this guide helps someone struggling to get Joomla working.
Hang in there, it is well worth the effort.
Re: Magic Quotes GPC Off ?
Post by humvee » Sun Oct 07, 2012 9:35 am
@silicon_chip Thanks for posting back with your latest solution. Just bear in mind that not everyone has access or permission to create local php.ini files on their hosting providers. Just make sure as above that the php.ini file is placed in both joomla_root/ and joomla_root/administrator/
The other solution is to find a host that configures their servers properly in the first place.
Re: Magic Quotes GPC Off ?
Post by schartier » Sun Oct 07, 2012 4:57 pm
Wow, thank you Silicon Chip. This works.
All I was missing was this.
Next we need to edit/create a .htaccess file in the root directory
it should have the following line:
SetEnv PHPRC /path /to/php.ini
The path will vary depending on your webhost
For example on my own site it is set as follows:
«SetEnv PHPRC /home/username/public_html/php.ini» where the username is my cpanel username.
Re: Magic Quotes GPC Off ?
Post by ttt007 » Mon Oct 08, 2012 9:35 am
Re: Magic Quotes GPC Off ?
Post by Sponsi » Tue Oct 09, 2012 6:31 am
Re: Magic Quotes GPC Off ?
Post by sovainfo » Tue Oct 09, 2012 9:52 am
Don’t think removing proper error handling is the solutions to erroneous configurations. Do you really want your site users to tell you your infrastructure is wrongly configured?
Or do you want Joomla to set it off programatically?
Re: Magic Quotes GPC Off ?
Post by Sponsi » Tue Oct 09, 2012 10:04 am
Well, but this one is something which sticks out.
Anyway, in one case 5.4 solved it, in other, CP configuration of the host.
Re: Magic Quotes GPC Off ?
Post by sovainfo » Tue Oct 09, 2012 11:31 am
Re: Magic Quotes GPC Off ?
Post by Sponsi » Tue Oct 09, 2012 11:43 am
This error touches something which needs editing on many hosts and not all hosts allow php.ini change.
Switching PHP to 5.4 solved this problem. The question is whether to treat this issue as an enforcerer for people to move to 5.4 or something?
Re: Magic Quotes GPC Off ?
Post by humvee » Tue Oct 09, 2012 12:29 pm
Re: Magic Quotes GPC Off ?
Post by Sponsi » Tue Oct 09, 2012 12:36 pm
humvee OK, you know, I could list a few other «good practices» but this is the question of balance.
Well, 2.5 installed just fine wherever I wanted, nothing ever needed changes.
This is the main idea I’m talking about — the extent to which hosts will agree to make such changes. I was lucky I always use high quality hosts, not too cheap, etc.
Re: Magic Quotes GPC Off ?
Post by DesignGuy » Thu Oct 11, 2012 5:22 pm
Re: Magic Quotes GPC Off ?
Post by 3rdlion » Thu Oct 11, 2012 11:39 pm
a workaround Magic Quotes and Joomla 3.0
Post by 3rdlion » Fri Oct 12, 2012 2:08 am
I decided to move this into its own thread. Hopefully this saves some other people time in getting their Joomla 3.0 site up and running.
Preamble
I’ve been seeing quite a few questions relating to Magic Quotes needing to be turned off in order to install Joomla 3.0 Many of the responses ask you to alter the php.ini or edit other high level server config.
All of this unnecessary server tinkering is just madness!
You can’t even install Joomla 3.0 without turning off Magic Quotes.
And its these kind of UX blocks that put Joomla so far backwards it’s not even funny.
In many cases altering php.ini is just not possible (shared hosting etc).
Magic Quotes Enable sites have existed no problem alongside Anti Magic Quotes sites, so what changed in Joomla 3.0? Why should you alter your server config?
With some careful editing, you can turn the clock back to the way things used to be and use Joomla 3.0 with Magic Quotes turned ON!