We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26074
    • 121 Posts
    I trying to make a snippet to use bbclone for a statistic system.

    The snipper bbclone is this
    <?php
    $_SERVER['HTTP_USER_AGENT'] = $HTTP_USER_AGENT;
    $_SERVER['HTTP_REFERER'] = $HTTP_REFERER;
    $page_title=$modx->documentObject['pagetitle'];
    define("_BBC_PAGE_NAME", "$page_title");
    define("_BBCLONE_DIR", "statistiche/");
    define("COUNTER", _BBCLONE_DIR."mark_page.php");
    [color=red]include_once(COUNTER);[/color]
    ?>
    


    The line in red is the problem. When I try to launch the site happen this error:
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »
     
    PHP error debug
      Error: 	include_once() [function.include-once]: URL file-access is disabled in the server configuration	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	C:\Programmi\xampp\htdocs\danielemeo\manager\includes\document.parser.class.inc.php(769) : eval()'d code	 
      Line: 	16	 
     
    Parser timing
      MySQL: 	0.0200 s	(3 Requests)
      PHP: 	0.0800 s	 
      Total: 	0.1000 s
    


    How I solve this?
    Thanks.
      ___________________________________________________________________
      ..:: Samuele ::..
      • 22303 MODX Staff
      • 10,725 Posts
      As the PHP error says, "URL file-access is disabled in the server configuration" and you are trying to include the file via URL rather than a proper local file system path.
        • 26074
        • 121 Posts
        But the problem is in xampp or modx?
          ___________________________________________________________________
          ..:: Samuele ::..
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Looks like this line is your problem
          define("_BBCLONE_DIR", "statistiche/");

          might work if you use "./statistiche/", or $modx->config[’base_path’] . "statistiche/", if that is in fact the correct relative path to the directory.

          For a snippet, the relative path would start at your web root, since it’s run through the index.php file in your web root. So you need to set the paths accordingly.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 26074
            • 121 Posts
            I changed the _BBCLONE_DIR but don’t work. Then I have insert the code in the file index.php of modx and work correctly.
            I don’t understand because the same code insert directly in index.php work and in a snippet not work. Bah... huh >:(
              ___________________________________________________________________
              ..:: Samuele ::..
              • 22303 MODX Staff
              • 10,725 Posts
              Your going to need to provide details if you want additional assistance...

              What did you change it to, $modx->config[’base_path’] . "statistiche/"? What was the actual resulting error when you changed it? Was it the same/different? Help us help you.
                • 26074
                • 121 Posts
                Ok... I try to explain better the problem.

                I installed a new modx 0.9.6.1 end a new bbclone script.
                This is the structure of the folders in htdocs of xampp

                C:\Programmi\xampp\htdocs\modxsite

                modxsite
                |__ assets
                |__ manager
                |__ statistiche <-- bbclone directory
                |__ index.php

                Then I create a new snippet called bbclone and I insert it in template using [!bbclone]]

                This is code of the snippet
                $_SERVER['HTTP_USER_AGENT'] = $HTTP_USER_AGENT;
                $_SERVER['HTTP_REFERER'] = $HTTP_REFERER;
                $page_title=$modx->documentObject['pagetitle'];
                define("_BBC_PAGE_NAME", "$page_title");
                define("_BBCLONE_DIR", "statistiche/");
                define("COUNTER", _BBCLONE_DIR."mark_page.php");
                if (is_readable(COUNTER)) include_once(COUNTER);
                


                ...but don’t work. When I load the page "http://localhost/modxsite/index.php" and then "http://localhost/modxsite/statistiche" the counter of bbclone not increase.

                Instead, the same code inserted at the end of modx file index.php work correctly.

                It’s strange. Not?
                  ___________________________________________________________________
                  ..:: Samuele ::..