On Thu, May 28, 2009 at 8:37 PM, Tom Worster <fsb@xxxxxxxxxx> wrote: > On 5/28/09 2:06 PM, "Nitsan Bin-Nun" <nitsan@xxxxxxxxxxxx> wrote: > > > i have tried this: > > > > <?php if (!defined('THROUGH_INDEX')) die('Sorry mate!'); > >> > >> $default_locale = setlocale(LC_ALL, 'en_US.UTF-8'); > >> ini_set('default_charset', 'UTF-8' ); > >> > >> > >> $_GET['folder'] = > >> > preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$_GET['folder'] > >> ); > >> > >> $dirname = $config['walls_dir'].$_GET['folder']."/".$_GET['filename']; > >> > >> > >> if (!is_file($dirname)) { echo "leave();"; g($dirname);die;} > >> > > > > > > I'm still getting: > > > >> leave(); > >> > >> string(56) "/home/nitsanbn/public_html/iphoneia/walls/חלל/008.jpg" > >> > >> > > The preg_replace() above convert the Hebrew chars into UTF8. > > The conversion does work but the file is not recognized as a file, > although > > that i can browse it straightly. > > why do you think that you need to do any conversion at all? > > that preg_replace looks terrifying! how did you come by it? i'm immediately > suspicious that this is the problem. > > i googled the code and found people claiming that it translates window-1255 > to utf8 (2004, dubious) and iso-8859-1 to utf-8 (2005, dubious). I came to that after a while, it is very common within Israeli developers ;) > > > if you know that the browser is sending the GET variable 'folder' in a > known > encoding other than utf8, why not convert it with mb_convert_encoding or > iconv? > > alternatively, force the user agent to send it in utf8 by sending the form > as utf 8 (send header('Content-Type: text/html; charset=utf-8'), and use > accept-charset="utf-8" in the form tag) and don't convert. then you can > avoid all conversions. > That's the thing, I do NOT know the encoding of the GET parameters. They are not submitting any form, the request is made through a link (<a> tag). > > > > I'm afraid that I don't have access to the php.ini, since it's a shared > > hosting, do you know if hostgator gives access to php.ini or let you > changes > > it's values? > > i have no idea. but i imagine it is sufficient to use ini_set(). > > > I have used the ini_set() you submitted but no luck yet. Any further ideas or suggestions will be appreciated :)