We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8136
    • 9 Posts
    I just installed mod x and was wondering...
    1. In every directory you have a index page that says access forbidden. Why not use
    <?php
    header("Location: http://yoursite.com/index");
    ?>
    

    or a redirect to a 404 page. I mean security by obscurity is kind of weak. Or at least set up sessions or something.
    2. Here is my old template system
    <?php
    class Page
    {
      var $page;
    
      function Page($template = "template.html") {
        if (file_exists($template))
          $this->page = join("", file($template));
        else
          die("Template file $template not found.");
      }
    
      function parse($file) {
        ob_start();
        include($file);
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
      }
    
      function replace_tags($tags = array()) {
        if (sizeof($tags) > 0)
          foreach ($tags as $tag => $data) {
            $data = (file_exists($data)) ? $this->parse($data) : $data;
            $this->page = eregi_replace("{" . $tag . "}", $data,
                          $this->page);
            }
        else
          die("No tags designated for replacement.");
      }
    
      function output() {
        echo $this->page;
      }
    }
    ?>

    and my old template
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
        <title>{title}</title>
    		<meta name="keywords" content="{keywords}" />
    		<meta name="description" content="{descript}" />
        <meta name="robots" content="index,follow"/>
        <meta name="rating" content="general"/>
        <meta name="revisit-after" content="7 days"/>
        <meta http-equiv="Content-Type" 
              content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="master.css" type="text/css" />
    		<style type="text/css">
      .{activemenu} a{border-bottom:solid 1px #FFFFFF;
    background-color:#ffffff;
    color:#000000;
    overflow:visible;
    diplay:block;}
    </style>
    {extracss}
    		{javascript}
    		{javascript2}
      </head>
      <body>
    	<div id="page">
        <div id = "header">
          <a href="index.php"><img src="logo.png" width="381" height="60" alt="Ask A Smart Guy" /></a>
          <div class="menutop">
    			{menutop}
    			</div>
    			<div class="menubottom">
    			{menubottom}
    			</div>
    			<div class="date">{date}
          </div>
    			
        </div>
        <div class="main">
          {main}
        </div>
        <div class="ads">
          {ads}
        </div>
        <div class="footer">
      {footer}
        </div>
    		</div>
    		{urchin}
      </body>
    </html>

    And the maker
    <?php
    require_once("template.php");
    $page = new Page("template1.php");
    
    $page->replace_tags(array(
      "title" => 'Welcome to my website',
    	"date" =>  'dat/date.dat',
    	"keywords" => 'dat/keywords.dat',
    	"extracss" => '',
    	"javascript" => 'dat/java.dat',
    	"javascript2" => '',
      "descript" => 'Welcome to my website!',
      "menubottom" => 'dat/menubottom.dat',
    	"activemenu" => 'menuitem1',
      "menutop" => 'dat/menutop.dat',
      "main" => 'dat/main.dat',
      "ads" => 'dat/ads.dat',
      "footer" => 'dat/footer.dat',
    	"urchin" => 'dat/urchin.dat'
    ));
    
    $page->output();
    ?>

    I thought it was pretty easy to use if I wanted to put php above the HTML doc type I would put {php} or something this cms seems to run similar but is also a little more complicated by a gui.
    3. I’m sure this project started out simple until 12 cooks got into the room. I mean I really cannot complain since it is a free cms. But what is the difference between a CMS and Blogging software?
    4. while this was my menu system for a directory
    <?php
    $dir = "../this-weeks-top-ten";
    $dh  = opendir($dir);
    while (false !== ($filename = readdir($dh))) {
        $files[] = $filename;
    }
    $unwantedfiles= array('.','..','dat','index.php','logo.png','master.css','template.php','template1.php'); 
    $result = array_diff($files, $unwantedfiles);
    $results = array_values($result);
    echo "<div class='menutopten'>"; 
    foreach ($results as $value){
    $values=str_replace('.php','',$value);
    $values=str_replace('-',' ',$values);
    $values=ucwords($values);
    echo "<a href='$dir/$value' >$values</a>";
    }
    echo "</div>";
    ?> 
    

    Now I have to figure out which page is 300 or something like that to make a menu, well I don’t because you have it on the sidebar in the admin, but do you understand what I mean.
    5. Anyways I have to look for something that suits my needs a little better.
    Good luck to you and this project.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      1. the purpose is simply to prevent directory listings if these are enabled in the web server configuration. Manager files do have internal checks to make sure they are not being called out of order, and it is perfectly possible for developers to do much the same for their snippets and such. But this also prevents the listing of the images and other directories that one may not wish to have a directory listing for.

      As far as the rest of it goes, like any other software, there is a learning curve. MODx is not exactly just a CMS, it is primarily a CMF, and has its advantages and disadvantages, depending on what you want to do. It certainly makes no claims to suit everybody.
        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
        • 21257 MODX Staff
        • 730 Posts
        Before I started using MODx, I coded everything from scratch in PHP. (Been using PHP since 1995, so I know it pretty well.)

        Still, I do some stuff that way.

        The more I get used to the facilities and flexibility of this framework, the more things I learn to do faster and in a more modular and repeatable way than I can with home-brewed PHP.

        I understand some of your questions, and the only answer I really have is that it takes some time to step back and learn a new way of constructing things - making use of snippets, chunks, document variables, placeholders in novel ways instead of always relying on writing PHP.

        Your template code is pretty straightforward and I’ve used this kind of approach, and sometimes still do if I need to throw something super quick and simple together. It doesn’t provide the same facilities as the MODx parser - recursive parsing of chunks, variables and code snippets. It’s just a different animal.

        I’m fairly certain that, depending on how you decide to store your top 10s in the MODx framework, you could accomplish your #4 on one line in MODx.
        Regarding #5, well, no solution is right for everyone and every situation. I can say from experience that I found it very much worth my time to stick with it. I was very anti-CMS to begin with, and MODx was the only architecture that made sense to me, even if it took a while for things to start to gel.

        Good luck in your adventures!
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 33372
          • 1,611 Posts
          I also used to code everything from scratch in PHP. Then I discovered MODx (by way of Etomite). It allowed me to focus on coding more interesting and unique things than just the basics.

          I like your first suggestion, though. In terms of security it doesn’t make much difference, but I always like to show people a real page whenever possible. And your solution actually adds more "security by obscurity", in that someone who attempts to load the default file for a given directory won’t even know that it exists (since they’ll be forwarded).

          Your suggestion about using sessions makes me believe that you’re fundamentally misunderstanding the way that MODx is set up and how it is secured, but your comments are welcome anyway.
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 8136
            • 9 Posts
            Thanks for the answers just wondering if you guys are still hear. I have to say that I had to step back and look at the overall picture and breathe deeply. I am going to start reading the docs from 1 - end and after playing with the zend framework this should be a breeze. laugh
              • 21257 MODX Staff
              • 730 Posts
              If you’re looking to get acquainted with MODx as a development framework, I might suggest digging in to 0.9.7-alpha instead. It is different enough from 0.9.6 and offers such significant advances (starting with a fully o-o API) that I would consider it a very different learning curve. Keep in mind it’s alpha, and pretty fresh alpha at that. If you’re considering this time as an investment, and want to keep pace with where MODx is headed, I’d recommend investing your time in learning 0.9.7. But if you’re looking to start pushing out some finished projects right away, with the benefit of support from the larger community, 0.9.6 is probably safest.
                Mike Schell
                Lead Developer, MODX Cloud
                Email: [email protected]
                GitHub: https://github.com/netProphET/
                Twitter: @mkschell