We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14332
    • 5 Posts
    Hello All,

    I am new to this board and was hoping that someone can help me because
    I am extremely frustrated.

    Let me just give you a rundown of what I am using ModX for in the first
    place. I maintain Cal Poly’s IEEE student branch’s web site at:
    http://www.calpolyieee.org and I have a bunch of project managers that
    need easy access to project pages. Most of my site does not use ModX
    at all, only the project pages do. I create users in ModX and then give
    them permission to access there own project pages. Then I just "used" to
    use an include(’http://www.calpolyieee.org/modx/index.php?id=5’); lines of
    php code to pop in the project page in ModX into the main projects page.

    However I just upgraded to the newest version of ModX the way I was
    instructed to and everything seemed to work fine on the ModX end.
    However, the rest of my site became dysfunctional. None of the php include
    url statements worked anymore. All of the url includes just time out.
    And I know it is bad to allow url include,
    but it was working fine and now its not. Please help, any suggestions
    are welcomed!

    Thanks!
      • 20413
      • 2,877 Posts
      Try switch off "Check HTTP_REFERER-headers" in config.
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 36678
        • 152 Posts
        I had a similar problem and came up with it longer. Thank you mrhaw!
          Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
          My sites:
          Мисли, интересни мисли
          • 14332
          • 5 Posts
          Hello mrhaw,

          Thank you for your quick response. Check HTTP_REFERER-headers is already turned off in ModX config
          and I can manually type in the URL into the address bar just fine. For example you can view
          the page: http://www.calpolyieee.org/modx/index.php?id=7 in your browser outside of ModX just
          fine, but when I try to include it in another page, it spits this out:

          Warning: include(http://www.calpolyieee.org/modx/index.php?id=7) [function.include]: failed to open stream: Connection timed out in /home/content/c/a/l/calpolyieee/html/announcements.php on line 323

          Warning: include() [function.include]: Failed opening ’http://www.calpolyieee.org/modx/index.php?id=7’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/content/c/a/l/calpolyieee/html/announcements.php on line 323

          Like I said before, this always used to work with no problems until I upgraded.
          But no include URL’s work now, not even ones to existing pages in my site, like:
          include (’http://www.calpolyieee.org/membership.php’); and my php5.ini has not changed,
          it still contains this data:

          upload_max_filesize = 90M
          post_max_size = 90M
          display_errors = off
          display_startup_errors = off
          register_globals = off
          allow_url_fopen = on
          allow_url_include = on
          memory_limit = -1
          max_input_time = 500
          max_execution_time = 500

          Thank you for your continued support! smiley
            • 20413
            • 2,877 Posts
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 3749
              • 24,544 Posts
              Using URL includes can result in timeouts if there are too many of them (and you need to set allow_url_include in PHP 5.2). You might try something like this instead:

              include $_SERVER['DOCUMENT_ROOT']."/lib/sample.lib.php";


              More ideas here: http://us.php.net/manual/en/function.include.php
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 14332
                • 5 Posts
                Thanks guys for responses, however, none of those solved the problem.
                I can include local files (ie. /membership.php, ../projects.php) and
                I can include other site’s URLS (ie. http://www.google.com), but I cannot
                include http://www.calpolyieee.org/modx/projects, which you can copy and
                paste into your address bar just fine and it works. I keep getting the
                timout issue.

                I switched over to using friendly URL’s hoping this would address the
                issue, but it doesn’t because ModX doesn’t actually create any of the
                files/directories in the site, it only redirects to the correct page
                when entered in the address bar which is very annoying if you are
                trying to do the sort of thing I am. Any further suggestions?

                If not, is there a way I can modify the modx code so that instead of
                $_GET(’id’), I can create a variable $id before the include function
                and have it passed into the modx code to have it spit out the page I want?

                Thank you for your continued support.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  You can’t just include the MODx index.php file or any alias of it routed via mod_rewrite (or similar tools). This automatically puts MODx Evolution in API mode and no request processing takes place. You need to read the the output of this URL request via curl, another HTTP client library, or by opening and reading the HTTP socket manually.
                    • 14332
                    • 5 Posts
                    Thanks for your response OpenGeek. I just tried using curl as well, with no luck.
                    Here is the code I tried to use, it does not work for any of my files, even the
                    ones outside of the modx directory like membership.php:

                    function get_data($url)
                    {
                    	$ch = curl_init();
                    	$timeout = 5;
                    	curl_setopt($ch,CURLOPT_URL,$url);
                    	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
                    	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
                    	$data = curl_exec($ch);
                    	curl_close($ch);
                    	return $data;
                    }
                    $returned_content = get_data('http://www.calpolyieee.org/modx/projects');
                    echo $returned_content;
                    


                    However this one does work:

                    function get_data($url)
                    {
                    	$ch = curl_init();
                    	$timeout = 5;
                    	curl_setopt($ch,CURLOPT_URL,$url);
                    	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
                    	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
                    	$data = curl_exec($ch);
                    	curl_close($ch);
                    	return $data;
                    }
                    $returned_content = get_data('http://www.google.com');
                    echo $returned_content;
                    


                    It seems as if all other URL’s work except for the ones local to the domain.
                    Or is this not what you were trying to suggest? Please let me know, because
                    I love all the ModX features and its power, but if I am unable to use them
                    outside of ModX, then the CMS isn’t much help.

                    Thanks!
                      • 22303 MODX Staff
                      • 10,725 Posts
                      These things work fine from my sites, and TBH, MODx is meant to be used as a framework. Integrating other software is up to how the other software is implemented. Regardless, I’m not sure what the issue is as I can get your site content fine.

                      Here is another approach:
                      <?php
                      $handle = fopen('http://www.calpolyieee.org/modx/projects', 'rb');
                      $content = '';
                      while (!feof($handle)) {
                          $content .= fread($handle, 8192);
                      }
                      fclose($handle);
                      echo $content;
                      ?>

                      This returns some HTML content on my local system, though not a valid HTML document...