Php Script That I Was Aksed To Make.

CabooseCaboose title = name(self, handle) Join Date: 2003-02-15 Member: 13597Members, Constellation
<div class="IPBDescription">For school.</div> Well, I don't really know PHP, but I am the teacher assistant for Mr. Powell the Comp Sci teacher. Anyway, he asked me to write him a php script and I told him I didn't know Php, well... I know the basic syntax of PHP, I just don't know most of the commands...

Anyway... I need a script that will go intop the /home directory on the comp sci server and use the finger command on the user names, then make a list of the users's real names as reported by finger and for those names to link to the /home/user/public_html directory.

I'm reading up on it, but since I'ma total noob at PHP, where else do I come? Ot forums, that's rite <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html//emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo-->

If anyone would help me out here, I'd appreciate it a lot. <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html//emoticons/smile-fix.gif' border='0' style='vertical-align:middle' alt='smile-fix.gif' /><!--endemo-->

Comments

  • Dorian_GrayDorian_Gray Join Date: 2004-02-15 Member: 26581Members, Constellation
    edited September 2004
    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1--><?php
    $delim = "Name:"; // May differ for different versions of "finger". This is the string directly before the data you want to extract.
    $directory = "/home"; // Self Explanatory
    $realnames = array();
    $usernames = array();

    if (!$dir = opendir($directory))
    {
     echo "Error opening directory $directory.";
    }
    else
    {
     while ($currentfile = readdir($dir))
     {
      if (is_dir($directory . "/" . $currentfile) && ($currentfile != ".") && ($currentfile != "..") && (substr($currentfile,0,1) != "."))
      {
       $usernames[] = $currentfile;
      }
     }
    }

    foreach ($usernames as $user)
    {
     $name = exec("finger {$user} | grep {$delim}");
     $name = substr($name,strpos($name,$delim) + strlen($delim) + 1);
     $realnames[] = $name;
     echo $name;
    }

    ?><!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

    That works with the most recent version of finger available for Gentoo. It should work no matter what the output, if configured properly.

    Edit: woops, that just gets the real names. I'll add the linkage, one moment.
  • CabooseCaboose title = name(self, handle) Join Date: 2003-02-15 Member: 13597Members, Constellation
    I can do that myself <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html//emoticons/smile-fix.gif' border='0' style='vertical-align:middle' alt='smile-fix.gif' /><!--endemo--> thanks dorian, much <3
  • Dorian_GrayDorian_Gray Join Date: 2004-02-15 Member: 26581Members, Constellation
    Okay. Sounds good <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html//emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo-->
Sign In or Register to comment.