We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29333
    • 26 Posts
    I can’t figure it out.
    For about an hour I tried everything .... but it doesn’t work as it should!
    I made a snippet that verifies if some file folders (directories) exist and if they don’t the snippet creates them...
    if ($modx->getLoginUserName() != '')
    {
      $usersdir = $modx->config['base_path'].'albume\\';  
      $usrdir = $usersdir .sha1($modx->getLoginUserName()) . '\\';
      $out = $usrdir;
      if(is_dir($usrdir)){
         $out .= '<br/><font color="#00CC00">Verified... OK. Directory exists.</font>';
      }
      else 
      {
       $out .= '<br/><font color="#FF0000">Verification failed! Invalid directory!</font>';
       if(is_dir($usersdir))
       { 
        if(mkdir($usrdir))
          {
          $out .= '<br/><font color="#00CC00">Your personal directory was succesfully created!</font>';
          }
        else
          {
          $out .= '<br/><font color="#FF0000">Failed to create your personal directory!</font>';
          }
       }
       else
         $out .= '<br/><font color="#FF0000">There was an error with the base dir of the users';
      }
    }
    else $out = 'You are browsing this site as guest, no info available.';
    return $out;


    What is wrong with it? Well... if the "Albume" directory exists and is empty, the snippet works just fine. If this directory exists and contains other folders (sha1-s of other users) but it doesn’t contain the one of the current user then the message returned is "Verified... OK. Directory exists.", and the funny part is that the snippet creates the folder of the current user.... It creates the folder but the mesage returned is as if the folder existed before the snippet made the verification....

    Is there sth wrong with the snippet ??
      Mosh-pit rules !!!
      • 29333
      • 26 Posts
      ANYONE huh embarrassed
        Mosh-pit rules !!!