The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cpanel has weird behavior

Discussion in 'General Discussion' started by Roy@ENHOST, May 9, 2003.

  1. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    Hi guys,

    There must be something weird about the CPanel directory system.

    I did the following script but it doesn't work.

    I put a dir.php on the root of my Cpanel skin.
    This script is supposed to output 'There is a mail folder' if it detects a folder with the name 'mail'
    Obviously there is a folder 'mail' in the cpanel skin, but i got an error.

    the code
    <?
    $handle = opendir(mail);

    while($filename = readdir($handle))
    {
    if ($filename != "." && $filename != "..")
    {
    if(is_dir($filename))
    print '<font color="#0033CC">There is a mail folder</font>';
    }
    }
    ?>


    The error
    Warning: OpenDir: No such file or directory (errno 2) in /tmp/cpanel.auto.1052482570.5401 on line 4

    Warning: readdir(): supplied argument is not a valid Directory resource in /tmp/cpanel.auto.1052482570.5401 on line 6



    What is wrong here?
    Is there any solution to this?
     
  2. Allowee

    Allowee Registered

    Joined:
    May 8, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    "$handle = opendir(mail);" is the problem...
    try
    "$handle = opendir("mail");" instead.
    should work.
    it that doesn't work becouse there is no 'mail' dir in /tmp you need to give the full path..
    "$handle = opendir("/full path where you want to look/mail");"
     
    #2 Allowee, May 9, 2003
    Last edited: May 9, 2003
  3. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    Re: Re: Cpanel has weird behavior

    I tried adding the " but it still doesnt work.
     
  4. Allowee

    Allowee Registered

    Joined:
    May 8, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    thinking about it......
    PHP:
    <?php
    if( @is_dir("mail") ){ 
     echo 
    "There is a mail folder";
    }
    ?>
    you are looking in a dir. but if it doesn't have permissions to allow apache to look in it it will fail.
    and look in a dir to see if it's there can be done with above code :)
    it just checks if "mail" is a dir, if not it doesn't return a errors because there is a '@' in front of it
     
  5. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    No good.:(

    There is still error

    Parse error: parse error in /tmp/cpanel.auto.1052493354.18381 on line 2
     
  6. Allowee

    Allowee Registered

    Joined:
    May 8, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    do you have any idea what code is around line 2

    i just checked on php.net...
    it's not a new function so it should work...
    but what i did saw was about an extra /

    so "mail/" is how it should be...

    but that won't get a parse error..
    so i guess you need to post a bit (password free) code
     
  7. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    the code is exactly the same as the one I gave you:

    <?phpif( @is_dir("mail") ){ echo "There is a mail folder";}?>

    But it doesnt work because of the weird way CPanel parses directory. Is there anyway around this?
    Does anyone know where the MAIL folder is in the TMP folder?
     
  8. Allowee

    Allowee Registered

    Joined:
    May 8, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    in your first post you said you wanted to look in the skin directory?
    then it should be something like
    <?php
    if( @is_dir("/usr/local/cpanel/base/frontend/skin_name/mail/") ){
    echo "There is a mail folder";
    }
    ?>
    and if that still doesn't wrk you can try putting a chdir("/blah"); before the if()

    i haven't looked how to 'rip' the users skin.. it should be somewhere so change the cofde for that.
    and if it still doesn't work you should post the full warnings/parse errors.

    btw, is that the only php you use in that file? it could be that '<?php' is already used. so you can also try to remove '<?php' and '?>'

    good luck :)
     
Loading...

Share This Page