Forums | Mahara Community

Support /
trouble with magic quotes


anonymous profile picture
Account deleted
Posts: 3

03 February 2010, 20:34

Hello,

Our installation is on a shared server where Magic Quotes are enabled. The host said I can create a php.ini file and place it in our Mahara directory, which I did. It says magic_quotes_gpc = off . The Magic Quotes warning is now gone from the Mahara home page, but warnings still appear in just about all other areas of the site. I can close the warning so I don't see the ugly errors, but when I log out and then log back in they appear again.

Is there some code I can add to certain files or something I can edit  in my files to tell Mahara to ignore or override  Magic Quotes? 

 Similar errors appear on just about all pages I access. Two examples are below. One from the Profile page, the other from the My Portfolio page.

Error from Profile page:

Call stack (most recent first):
  • log_message("You have dangerous PHP settings, magic_quotes_gpc ...", 1, true, true) at /home/gmpdcor2/public_html/mahara/lib/errors.php:123
  • log_environ("You have dangerous PHP settings, magic_quotes_gpc ...") at /home/gmpdcor2/public_html/mahara/lib/mahara.php:97
  • ensure_sanity() at /home/gmpdcor2/public_html/mahara/init.php:80
  • require("/home/gmpdcor2/public_html/mahara/init.php") at /home/gmpdcor2/public_html/mahara/artefact/internal/index.php:34

Error from My Portfolio page:
 
Call stack (most recent first):
  • log_message("You have dangerous PHP settings, magic_quotes_gpc ...", 1, true, true) at /home/gmpdcor2/public_html/mahara/lib/errors.php:123
  • log_environ("You have dangerous PHP settings, magic_quotes_gpc ...") at /home/gmpdcor2/public_html/mahara/lib/mahara.php:97
  • ensure_sanity() at /home/gmpdcor2/public_html/mahara/init.php:80
  • require("/home/gmpdcor2/public_html/mahara/init.php") at /home/gmpdcor2/public_html/mahara/view/index.php:35
 
This is shaky territory for me so please be very specific with what I need to edit. Any assistance is most appreciated.
 
:>)

 

04 February 2010, 3:06

Hello Liane,

Normaly you can't access php.ini if you are not the webmaster of your site. 

You can turn on/off php function by putting instruction into a special file you will upload in your mahara folder.

  1. Use a text editor and type
  2. php_flag magic_quotes_gpc off 
  3. Save this file as ".htaccess" into your Mahara folder

This should solve your problem.

If you can edit the php.ini be aware you are changing information for the whole site. By using a .htaccess file you can change the php behaviour service by service, which is better.

HTH

-dajan

anonymous profile picture
Account deleted
Posts: 3

04 February 2010, 8:24

Good morning and thanks for your prompt response. I tried that with the .htaccess file but then got a 500 error. The problem is that I probably didn't enter it correctly or missed something.  Do I need any brackets or hash characters? Once a site is up, I'mOK at running it, but these backend issues spin me a bit.

 Please be so kind and show me where/how to insert this. Here's the text from my .htaccess file:

 <Files .htaccess>
    Order deny,allow
    deny from all
</Files>
<Files lib.php>
    Order deny,allow
    deny from all
</Files>

# HTTP performance. This stuff tested in apache2 only.
# Enable mod_expires, mod_headers and mod_deflate!

#<IfModule mod_deflate.c>
#    AddOutputFilterByType DEFLATE text/html text/css application/x-javascript
#</IfModule>

#<IfModule mod_headers.c>
 #   Header unset ETag
#</IfModule>
FileETag None

Thank you so much for your help. I've been working on getting Mahara installed for a few days...I'm *almost* there! Wink

04 February 2010, 17:26

Well

I think that you could edit your .htaccess as follow :

---- Begin copy ------

#Disable magic_quotes for this folder
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off

 <Files .htaccess>
    Order deny,allow
    deny from all
</Files>
<Files lib.php>
    Order deny,allow
    deny from all
</Files>

# HTTP performance. This stuff tested in apache2 only.
# Enable mod_expires, mod_headers and mod_deflate!

#<IfModule mod_deflate.c>
#    AddOutputFilterByType DEFLATE text/html text/css application/x-javascript
#</IfModule>

#<IfModule mod_headers.c>
 #   Header unset ETag
#</IfModule>
FileETag None

---- End copy -----

I am surprised to see the <File ...> command in your .htaccess. Normaly this command is used on Apache < 1.3 but has been remplaced with  <FilesMatch> from 1.3 to Apache 2.

 You will find an explanation of all commands here for exemple.

HTH

anonymous profile picture
Account deleted
Posts: 3

05 February 2010, 18:37

Hello and thanks  for your kind reply!

This did not work for me and it's not soemthing I don't know enough about hand editing .htaccess files. But, I did do some reading and I'm wondering if I have to insert an "allow override in the .htaccess to be able to do the opposite of the host server's default settings.

Any thoughts?

 

:>)

 

 

anonymous profile picture
Account deleted
Posts: 6

14 November 2010, 23:46

Since I am split-new here, I hope I can ask some silly questions.

1. Why there are magic quotes? What causes them in the first place?

2. Would stopping them from getting disaplyed solve the issue that causes the problem?

3. Why no Mahara documentation mentions this and shows a wayout?

4. I am using MySql, which is not Mahara's cup of tea. Would this itself create problems?

Thanks for responses in advance.

anonymous profile picture
Account deleted
Posts: 5

15 November 2010, 7:48

What version of PHP is the host using?  Using the host's suggestion may be ineffective as disabling magic quotes via php.ini has been deprecated in PHP 5.3.0.  The directive may only be disabled at the system level, and not at runtime. In otherwords, use of ini_set() is not an option.

A general comment to the Mahara project: it would seem that the inclusion of Mahara into Fantastico would benefit the Mahara community.  Particularly as general-purpose web 2.0 tools like WordPress or CMS systems may readily be employed to meet educational ePortfolio requirements, anything that can be done to bolster the general education industry's adoption of Mahara would be in the project's self-interest.  Revenue can still be found in your offering dedicated hosting alternatives and/or custom plug-ins, but since the education industry is generally not-for-profit there are rarely funds available to support niche software that requires expertise long-term.

anonymous profile picture
Account deleted
Posts: 5

15 November 2010, 11:58

I re-read the orgininal post "the Magic Quotes warning is now gone from the Mahara home page, but warnings still appear in just about all other areas of the site."  In this case, the cause is likely that these files do not support inheritance and must be copied in each directory of the site, which requires the settings in question. If you copy the php.ini file recursively in all directories you should find the warning message is no longer displayed on your website.

anonymous profile picture
Account deleted
Posts: 24

16 May 2011, 13:15

For me none of the "solutions" to get rid of the magic_quotes-gpc Warning worked.

I have tried every proposed  .htaccess file with no reaction.The server is running with php 5.3, since 5.2.6 which seems to be the most popular stable php Version does not meet any more the Systemrequirements of Moodle 2.0.3

On the other hand someone said, in 5.3 it is no longer possible to disable magic_quotes_gpc via php.ini. So probably it would be more realistic to accept magic_quotes_gpc.

Therefor I ask: Is there perhaps any chance just to stop the alert?

At least mahara still seem to work even with magic_quotes-gpc but you cant work with it, if everybody has to close tons of Warnings for each single click he does..

best

Steffen

9 results