We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23510
    • 168 Posts
    I have a file TV. Some of the filenames have square brackets e.g. document[1].pdf.

    I also have a snippet to get the size of the file using filesize(), however for the files with square brackets in its name I get this:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: filesize() [function.filesize]: stat failed for /home/client/public_html/home/assets/files/document (NOTE:SQUARE BRACKET GETS CLIPPED OFF)
    Error type/ Nr.: Warning - 2
    File: /home/client/public_html/home/manager/includes/document.parser.class.inc.php(770) : eval()’d code
    Line: 5


    I have tried both rawurlencode() and urlencode() and they do not work.

    Any ideas? Thanks in advance.
      • 25663 MODX Staff
      • 12,272 Posts
      I’m guessing this is Evo?

      Regardless, you’ll need to provide a lot more info before we can help about your environment. See the "help us help you" link in my signature.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 23510
        • 168 Posts
        Thanks for the reply. I had a deadline to deal with so I manually renamed the file, then I found the FileDetails snippet.

        As for my info:


        PHP Version 5.2.14
        Server API - CGI
        MySQL 5.0.91-community
        CENTOS 5.5 x86_64
        Apache/2.0.63
        MODx Evo 1.03, no core changes, all other snippets work fine.

        Plugins: DirectResize and FixAmpersands (code below)

        $e = &$modx->event;
        $id = $modx->event->params['id'];
        if ($e->name == 'OnWebPagePrerender') {
            $o = &$modx->documentOutput; // get a reference of the output
            // Replace all ^text inside hats^ to <sup> tags, useful for more friendly Wayfinder replacements
            $o = preg_replace('%\^([()a-zA-Z0-9 ]*)\^%i', "<sup>$1</sup>",$o);
            // Replace orphan & with &
            $o = preg_replace('%&(?![a-zA-Z0-9#]{1,6})%i', "&",$o);
            // Replace ].]> with ]]>, useful for CDATA tags inside PHx calls: http://modxcms.com/forums/index.php?topic=31435.0
            $o = str_replace('/* ].]> */', '/* ]]> */',$o);
        }
        $e->output($o);
        return '';



        Problem is not specific to any browser or client OS but I am using win7/Firefox 3.6.10