Turning magic quotes off

Started on the old forum in October 2011 · view the original in the archive · old links redirect here

11 replies · 1,006 views · started 15 years ago · 1 min read

4 participants
rajveer Developer · 104 posts #1

Hai Friends i need to turn magic quotes gpc off but my host not allows me changes through htacess files php vers is 5.3.x can anyone tell me how to turn off it in using the php code i this file ?

<?
if (function_exists('ini_set'))
{
ini_set('display_errors',0); // отключаем показ ошибок
ini_set('register_globals', 0); // вырубаем глобальные переменные
ini_set('session.use_cookies', 1); // используем куки для сессий
ini_set('session.use_trans_sid', 1); // используем url для передачи сессий
ini_set('arg_separator.output', '&'); // разделитель переменных в url (для соответствия с xml)
}

if (ini_get('register_globals')) {
// принудительно вырубаем глобальные переменные
$allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
foreach ($GLOBALS as $key => $value) {if (!isset($allowed[$key]))unset($GLOBALS[$key]);}
}

list($msec, $sec) = explode(chr(32), microtime()); // время запуска скрипта
$conf['headtime'] = $sec + $msec;

define('DCMS_USE_MBSTRING', function_exists('mb_get_info'));
define('DCMS_USE_ICONV', function_exists('iconv'));
define('DCMS_USE_FFMPEG', class_exists('ffmpeg_movie'));
define('DCMS_USE_MCRYPT', function_exists('mcrypt_cbc'));
define('DCMS_USE_MYSQL', function_exists('mysql_info'));
define('DCMS_USE_GD', function_exists('gd_info'));
define('DCMS_SET_TIME_LIMIT', function_exists('set_time_limit'));
define('DCMS_USE_ERROR_REPORTING', function_exists('error_reporting'));
define('DCMS_CURL', function_exists('curl_init'));
define('DCMS_CURL_MULTI', function_exists('curl_multi_init'));
define('DCMS_TIME', time()); // текущее время
define('DCMS_TIME_TODAY',mktime(0, 0, 0)); // время на начало суток
$time=DCMS_TIME;

if (!DCMS_USE_MYSQL) die('Расширение MySQL недоступно');

if (DCMS_USE_ERROR_REPORTING)@error_reporting(0); // отключаем показ ошибок
// Ставим ограничение для выполнения скрипта на 60 сек
if (DCMS_SET_TIME_LIMIT)@set_time_limit(60);

if (DCMS_USE_MBSTRING)mb_internal_encoding('UTF-8');
if (DCMS_USE_ICONV)iconv_set_encoding('internal_encoding', 'UTF-8');

$phpvervion=explode('.', phpversion());
$conf['phpversion']=$phpvervion[0];

$upload_max_filesize=ini_get('upload_max_filesize');
if (preg_match('#([0-9]*)([a-z]*)#i',$upload_max_filesize,$varrs))
{
if ($varrs[2]=='M')$upload_max_filesize=$varrs[1]*1048576;
elseif ($varrs[2]=='K')$upload_max_filesize=$varrs[1]*1024;
elseif ($varrs[2]=='G')$upload_max_filesize=$varrs[1]*1024*1048576;
}

?>
arnage Lead · 811 posts #4

U want to remove backslashes from displaying? If so u can use this.

if (get_magic_quotes_gpc()) $string = stripslashes($string);
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
rajveer Developer · 104 posts #5

No arngage bro u didnt got me my site is made from dcms bcaus of magic quotes my site is not working n showing displaying error ony words are showing like if css i not done look at my site u will understand i want to fully disable those but i cant do with php.ini or htacess so plz help me 🙁 how to close this via script

arnage Lead · 811 posts #6

arnage. 🙂 But if it can't solve that problem via php.ini and htaccess than its not problem due to get_magic_quotes_gpc().

This should be link to css file but it shows internal server error.

http://wap4talk.co.cc/style/themes/smarty_web/style.css

Post the content of your htacces file and if is there error_log.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
rajveer Developer · 104 posts #7
# ограничения на выгрузку файлов
# php_value upload_max_filesize 100M
# php_value post_max_size 100M

####################################################

# отключаем показ ошибок
php_value display_errors 0
# так безопаснее
php_value register_globals 0
# убираем экранирование кавычек
php_value magic_quotes_gpc 0
# дописываем сессию к URL
php_value session.use_trans_sid 1
php_value session.cookie_lifetime 0

# решение проблем с кодировкой
php_value default_charset UTF-8
####################################################

DirectoryIndex index.php
# Отключаем листинг директорий при отсутствии index.php
Options -Indexes

# задаем соответствие mime типов расширению
AddType text/vnd.wap.wml;charset=utf-8 .wml
AddType application/vnd.sonyericsson.mms-template tpl
AddType application/vnd.wap.wmlc .wmlc
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlscriptc .wmlsc
AddType image/vnd.wap.wbmp .wbmp
AddType application/vnd.eri.thm .thm
AddType application/vnd.mophun.application .mpn
AddType application/vnd.mophun.certificate .mpc
AddType text/vnd.sun.j2me.app-descriptor .jad
Addtype text/x-vmel .mel
Addtype audio/imelody .imy
AddType application/vnd.smaf .mmf
Addtype text/x-vmel .emy
AddType audio/amr .amr
AddType audio/x-wav .wav
AddType application/x-tar .hid
Addtype image/jpeg .jpg
Addtype image/jpeg .jpeg
Addtype image/gif .gif
Addtype image/png .png
Addtype image/bmp .bmp
Addtype text/x-imelody .imy
Addtype text/x-emelody .emy
Addtype text/x-vcard .vcf
Addtype text/x-vcalendar .vcs
Addtype text/calendar .ics
Addtype application/smil .smil
Addtype application/smil .smi
Addtype application/java-archive .jar
Addtype application/vnd.symbian.install .sis
Addtype audio/wav .wav
Addtype audio/midi .midi
Addtype audio/midi .mid
Addtype audio/rmf .rmf
Addtype application/vnd.wap.mms-message .mms
AddType video/flv .flv
AddType video/mp4 .mp4
Addtype video/3gpp .3gp
Addtype application/zip .zip
Addtype audio/mpeg .mp3

# переопределяем страницы ошибок
ErrorDocument 400 /err.php?err=400
ErrorDocument 401 /err.php?err=401
ErrorDocument 402 /err.php?err=402
ErrorDocument 403 /err.php?err=403
ErrorDocument 404 /err.php?err=404
ErrorDocument 500 /err.php?err=500
ErrorDocument 502 /err.php?err=502

i have comented those php values bcaus my site goes 500 error if do dat n its working on xamp where magic quotes are turned offf i think i have to buy a paid host 🙁

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close