We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: sottwell at Jul 09, 2009, 12:18 AM

    getDocumentOutput: Print output of a document.
    I have often thought it was a pity that the document parser ends with an echo statement; it would be very useful sometimes if it just returned the documentOutput, and the index.php did the echo, so that one could use the parser to get the document’s output for other purposes (besides in a plugin).
    Another of the main reasons for the object-oriented rewrite; modResource->process() returns the cacheable content of a resource; then rendering the non-cacheable final output is a matter of running it through the modParser->processElementTags() function. However, you also have to keep in mind that returning the output rather than just echo’ing generally takes a lot more memory, and in some cases, that can be a problem.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes, (about the memory), and the page headers have already been sent as well, so things could get ugly.
        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
        • 20413
        • 2,877 Posts
        I can’t get the latest zip to work with either winzip or winrar embarrassed

        Is it my vista 64???
          @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
          • 33992 ☆ A M B ☆
          • 455 Posts
          The zip file was damaged. I attached it to first post.
          Thanks.
            God loves me. 【ツ】


            MODX.ir (Persian Support)

            Boplo.ir/modx/ (Persian)
            • 20413
            • 2,877 Posts
            Sweet! cool cool cool
              @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
              • 26692
              • 3 Posts
              I’m find Bug :

              function getPrivateDocs (
              ...
              $assigned[] = $wgs[0];
              $IN = join(",", $unassigned);

              must be ...

              $IN = join(",", $assigned);

                • 33992 ☆ A M B ☆
                • 455 Posts
                Quote from: sequent at Jul 16, 2009, 04:44 PM

                I’m find Bug :...
                Updated, Thank you smiley
                  God loves me. 【ツ】


                  MODX.ir (Persian Support)

                  Boplo.ir/modx/ (Persian)
                  • 33992 ☆ A M B ☆
                  • 455 Posts
                  The codes below gets last comments in site. first line gets last ones from manager last login and second line gets last 10 comments of site like similar feature in Wordpress.
                  <?php
                  // From my last login
                  $lastComments = $cake->comment_byWhere('jot.createdon > '.$_SESSION['mgrLastlogin'], '*');
                  
                  // last ten comments
                  $lastComments = $cake->comment_byWhere('jot.id > 0 ORDER BY jot.createdon DESC LIMIT 10', '*');


                  The result is array contins database rows and can be printed easily like this:
                  <?php
                  foreach($lastComments as $comment)
                  	echo "<b>{$comment['name']}</b>: " .substr($comment['content'], 0, 100). "...<br />";
                    God loves me. 【ツ】


                    MODX.ir (Persian Support)

                    Boplo.ir/modx/ (Persian)
                    • 33992 ☆ A M B ☆
                    • 455 Posts
                    Login sample. The logic is from WebLoginPE snippet.
                    <?php
                    $username = $cake->escape( $cake->stripModxTags($_POST['username'], true) );
                    $password = md5( $cake->escape( $cake->stripModxTags($_POST['password'], true) ) );
                    $time = time();
                    
                    if(!isset($username) || !isset($password))
                    	return "Fill necessary fields!";
                    
                    if(! $userId = $cake->getUserField(0, 'id', 'web_user', "username='$username'") )
                    	return "Wrong Username entered!";
                    
                    if(! $attrs = $cake->getUserField($userId, '*', 'web_user_attributes') )
                    	return "An error occured!";
                    
                    if(! $cake->getUserField(0, 'id', 'web_user', "username='$username' AND password='$password'") )
                    {
                    	$cake->updateUserProfile($userId, 'web_user_attributes', array('failedlogincount' => $attrs['failedlogincount']+1));
                    	return "Wrong password entered!";
                    }
                    
                    if( isset($modx->config['allowed_ip']) && strpos($modx->config['allowed_ip'], $cake->getIP()) === false)
                    	return "You can not access to site!";
                    
                    if (isset($modx->config['allowed_days']))
                    {
                    	$date = getdate();
                    	$day = $date['wday']+1;
                    	if(strpos($modx->config['allowed_days'], $day) === false)
                    		return "You can not login today!";
                    }
                    
                    if($attrs['blocked'] == 1)
                    	return "You have been blocked by site admins!";
                    
                    if($attrs['blockedafter'] != 0 && $attrs['blockedafter'] < $time)
                    	return "You have been blocked from " .$time - $attrs['blockedafter']. " seconds ago!";
                    
                    if($attrs['blockeduntil'] > $time)
                    	return "You have been blocked for " .$attrs['blockeduntil'] - $time. " seconds";
                    
                    if($attrs['failedlogincount'] >= $modx->config['failed_login_attempts'])
                    {
                    	$cake->updateUserProfile($userId, 'web_user_attributes', array('failedlogincount' => $attrs['failedlogincount']+1));
                    	return "You had many failed login count!";
                    }
                    
                    $cake->updateUserProfile($userId, 'web_user_attributes', array('lastlogin'=>$time, 'logincount'=>$attrs['logincount']+1));
                    
                    $active_users_tbl = $cake->getFullTableName('active_users');
                    $insert = array('internalKey'=>$userId, 'username'=>$username, 'lasthit'=>$time, 'id'=>'0', 'action'=>'998', 'ip'=>$cake->getIP());
                    if( $cake->db->getRecordCount( $cake->db->select('internalKey', $active_users_tbl, "internalKey=$userId") ) == 0 )
                    	$cake->db->insert($insert, $active_users_tbl);
                    else
                    	$cake->db->update($insert, $active_users_tbl, "internalKey=$userId");
                    
                    $_SESSION['webShortname'] = $username; 
                    $_SESSION['webFullname'] = $attrs['fullname']; 
                    $_SESSION['webEmail'] = $attrs['email']; 
                    $_SESSION['webValidated'] = 1; 
                    $_SESSION['webInternalKey'] = $userId; 
                    $_SESSION['webValid'] = base64_encode($password); 
                    $_SESSION['webUser'] = base64_encode($username); 
                    $_SESSION['webFailedlogins'] = $attrs['failedlogincount']; 
                    $_SESSION['webLastlogin'] = $time; 
                    $_SESSION['webnrlogins'] = $attrs['logincount'] + 1;
                    $_SESSION['webUserGroupNames'] = array();
                    
                    $selectWebGroups = $cake->db->query("
                    	SELECT gn.name FROM ".$cake->getFullTableName('web_groups')." g, ".$cake->getFullTableName('webgroup_names')." gn 
                    	WHERE gn.id = g.webgroup AND g.webuser = $userId"
                    );
                    while($group = $cake->db->getRow($selectWebGroups, 'num'))
                    	$_SESSION['webUserGroupNames'][] = $group[0];
                      God loves me. 【ツ】


                      MODX.ir (Persian Support)

                      Boplo.ir/modx/ (Persian)
                      • 33992 ☆ A M B ☆
                      • 455 Posts
                      Simple Logout.
                      <?php
                      $active_users_tbl = $cake->getFullTableName('active_users');
                      $cake->db->update("lasthit='0'", $active_users_tbl, "internalKey=".$_SESSION['webInternalKey']);
                      unset(
                      	$_SESSION['webShortname'],
                      	$_SESSION['webFullname'],
                      	$_SESSION['webEmail'],
                      	$_SESSION['webValidated'],
                      	$_SESSION['webInternalKey'],
                      	$_SESSION['webValid'],
                      	$_SESSION['webUser'],
                      	$_SESSION['webFailedlogins'],
                      	$_SESSION['webLastlogin'],
                      	$_SESSION['webnrlogins'],
                      	$_SESSION['webUserGroupNames']
                      );
                        God loves me. 【ツ】


                        MODX.ir (Persian Support)

                        Boplo.ir/modx/ (Persian)