Windows to Unix text doc parsing problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • programming

    Windows to Unix text doc parsing problem

    Hi all,

    i have been having trouble with a login script that works on my
    windows machine, however when i upload it to the Unix server through
    VPN, the same script won't work! It won't parse member.txt properly i
    think. The password and usernames i am using are at the bottom of this
    post.
    Each time i go to login on the unix server, it clears the username and
    password field. I have been attempting to solve the problem, but have
    been baffled to see why there is such an issue. I have taken out the
    HTML, and just given you the PHP script that i am running. The
    original programming was done on Unix!.

    My question to people on here is why does my script run on Windows and
    not on Unix? How can i fix the problem?

    Here is the source code i have been looking at:
    \-------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <?
    session_start() ;

    if ($userid && $password)

    {
    //listf stores a reference to the file itself
    $listf=fopen("u sername/member.txt","r" );

    #read the file
    list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");

    $duserid=trim($ duserid);
    $dpassword=trim ($dpassword);

    //keep reading until the end of the file is reached
    while(!feof($li stf)){

    if(($userid==$d userid)&&($pass word==$dpasswor d))
    {
    $_SESSION['valid_user']=$userid;
    break;
    }
    list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
    $duserid=trim($ duserid);
    $dpassword=trim ($dpassword);
    }
    fclose($listf);
    }

    ?>
    ------HTML-------
    <?
    $tempstr=$_SESS ION['valid_user'];

    if (isset($_SESSIO N['valid_user'])){
    echo "You are logged in as: $tempstr<br>";
    echo "<a href=\"admin_ho me.php\">Admin Home</a><br>";
    }
    else{
    if (isset($userid) ) {
    // if they've tried and failed to log in
    echo "Could not log you in";
    }
    else{
    // they have not tried to log in yet or have logged out
    echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
    border=0 valign=\"top\" align=\"center\ ">";
    echo "<tr><td>Yo u are not logged in.<br></td>";
    echo "</table>";
    }
    // provide form to log in
    echo "<form method=post action=\"login. php\">";
    echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
    border=0 valign=\"top\" align=\"center\ ">";
    echo "<tr><td>Userid :</td>";
    echo "<td><input type=text name=userid></td></tr>";
    echo "<tr><td>Passwo rd:</td>";
    echo "<td><input type=password name=password></td></tr>";
    echo "<tr><td colspan=2 align=right>";
    echo "<input type=submit value=\"Log in\">";
    //echo "<tr><td colspan=1 align=center>";
    echo "<input type=reset value=\"Reset\" ></td></tr>";
    echo "</table></form>";
    }
    ?>
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Here is the Windows copy of the member.txt that only works with ASCII
    block terminator at the end of the file:
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------
    admin|1234|Scho ol|Computing|bh kang@utas.edu.a u|University of Tasmania|
    1
    bhkang|abcd1234 |Kang|ByeongHo| bhkang@utas.edu .au|Computing|2
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Cheers,

    Peri.

  • Jerry Stuckle

    #2
    Re: Windows to Unix text doc parsing problem

    programming wrote:
    Hi all,
    >
    i have been having trouble with a login script that works on my
    windows machine, however when i upload it to the Unix server through
    VPN, the same script won't work! It won't parse member.txt properly i
    think. The password and usernames i am using are at the bottom of this
    post.
    Each time i go to login on the unix server, it clears the username and
    password field. I have been attempting to solve the problem, but have
    been baffled to see why there is such an issue. I have taken out the
    HTML, and just given you the PHP script that i am running. The
    original programming was done on Unix!.
    >
    My question to people on here is why does my script run on Windows and
    not on Unix? How can i fix the problem?
    >
    Here is the source code i have been looking at:
    \-------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <?
    session_start() ;
    >
    if ($userid && $password)
    >
    {
    //listf stores a reference to the file itself
    $listf=fopen("u sername/member.txt","r" );
    >
    #read the file
    list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
    >
    $duserid=trim($ duserid);
    $dpassword=trim ($dpassword);
    >
    //keep reading until the end of the file is reached
    while(!feof($li stf)){
    >
    if(($userid==$d userid)&&($pass word==$dpasswor d))
    {
    $_SESSION['valid_user']=$userid;
    break;
    }
    list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
    $duserid=trim($ duserid);
    $dpassword=trim ($dpassword);
    }
    fclose($listf);
    }
    >
    ?>
    ------HTML-------
    <?
    $tempstr=$_SESS ION['valid_user'];
    >
    if (isset($_SESSIO N['valid_user'])){
    echo "You are logged in as: $tempstr<br>";
    echo "<a href=\"admin_ho me.php\">Admin Home</a><br>";
    }
    else{
    if (isset($userid) ) {
    // if they've tried and failed to log in
    echo "Could not log you in";
    }
    else{
    // they have not tried to log in yet or have logged out
    echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
    border=0 valign=\"top\" align=\"center\ ">";
    echo "<tr><td>Yo u are not logged in.<br></td>";
    echo "</table>";
    }
    // provide form to log in
    echo "<form method=post action=\"login. php\">";
    echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
    border=0 valign=\"top\" align=\"center\ ">";
    echo "<tr><td>Userid :</td>";
    echo "<td><input type=text name=userid></td></tr>";
    echo "<tr><td>Passwo rd:</td>";
    echo "<td><input type=password name=password></td></tr>";
    echo "<tr><td colspan=2 align=right>";
    echo "<input type=submit value=\"Log in\">";
    //echo "<tr><td colspan=1 align=center>";
    echo "<input type=reset value=\"Reset\" ></td></tr>";
    echo "</table></form>";
    }
    ?>
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Here is the Windows copy of the member.txt that only works with ASCII
    block terminator at the end of the file:
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------
    admin|1234|Scho ol|Computing|bh kang@utas.edu.a u|University of Tasmania|
    1
    bhkang|abcd1234 |Kang|ByeongHo| bhkang@utas.edu .au|Computing|2
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    >
    Cheers,
    >
    Peri.
    >
    Peri,

    You have register_global s enabled on your Windows machine (VERY BAD) and
    disabled on your Unix machine (VERY GOOD).

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • programming

      #3
      Re: Windows to Unix text doc parsing problem

      On Apr 5, 1:46 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      programming wrote:
      Hi all,
      >
      i have been having trouble with a login script that works on my
      windows machine, however when i upload it to the Unix server through
      VPN, the same script won't work! It won't parse member.txt properly i
      think. The password and usernames i am using are at the bottom of this
      post.
      Each time i go to login on the unix server, it clears the username and
      password field. I have been attempting to solve the problem, but have
      been baffled to see why there is such an issue. I have taken out the
      HTML, and just given you the PHP script that i am running. The
      original programming was done on Unix!.
      >
      My question to people on here is why does my script run on Windows and
      not on Unix? How can i fix the problem?
      >
      Here is the source code i have been looking at:
      \-------------------------------------------------------------------------------------------------------------------------------------------------------------------
      <?
      session_start() ;
      >
      if ($userid && $password)
      >
      {
      //listf stores a reference to the file itself
      $listf=fopen("u sername/member.txt","r" );
      >
      #read the file
      list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
      >
      $duserid=trim($ duserid);
      $dpassword=trim ($dpassword);
      >
      //keep reading until the end of the file is reached
      while(!feof($li stf)){
      >
      if(($userid==$d userid)&&($pass word==$dpasswor d))
      {
      $_SESSION['valid_user']=$userid;
      break;
      }
      list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
      $duserid=trim($ duserid);
      $dpassword=trim ($dpassword);
      }
      fclose($listf);
      }
      >
      ?>
      ------HTML-------
      <?
      $tempstr=$_SESS ION['valid_user'];
      >
      if (isset($_SESSIO N['valid_user'])){
      echo "You are logged in as: $tempstr<br>";
      echo "<a href=\"admin_ho me.php\">Admin Home</a><br>";
      }
      else{
      if (isset($userid) ) {
      // if they've tried and failed to log in
      echo "Could not log you in";
      }
      else{
      // they have not tried to log in yet or have logged out
      echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
      border=0 valign=\"top\" align=\"center\ ">";
      echo "<tr><td>Yo u are not logged in.<br></td>";
      echo "</table>";
      }
      // provide form to log in
      echo "<form method=post action=\"login. php\">";
      echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
      border=0 valign=\"top\" align=\"center\ ">";
      echo "<tr><td>Userid :</td>";
      echo "<td><input type=text name=userid></td></tr>";
      echo "<tr><td>Passwo rd:</td>";
      echo "<td><input type=password name=password></td></tr>";
      echo "<tr><td colspan=2 align=right>";
      echo "<input type=submit value=\"Log in\">";
      //echo "<tr><td colspan=1 align=center>";
      echo "<input type=reset value=\"Reset\" ></td></tr>";
      echo "</table></form>";
      }
      ?>
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Here is the Windows copy of the member.txt that only works with ASCII
      block terminator at the end of the file:
      ------------------------------------------------------------------------------------------------------------------------------------------------------------------
      admin|1234|Scho ol|Computing|bh k...@utas.edu.a u|University of Tasmania|
      1
      bhkang|abcd1234 |Kang|ByeongHo| bhk...@utas.edu .au|Computing|2
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------
      >
      Cheers,
      >
      Peri.
      >
      Peri,
      >
      You have register_global s enabled on your Windows machine (VERY BAD) and
      disabled on your Unix machine (VERY GOOD).
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===
      Ok Jerry thanks for the advice, it is strange that most of the code i
      have adapted here comes from some tutorial work i have been doing, and
      that
      it suppose to be tested initially on the Unix server. So, you are
      telling me that the problem is not in the program reading the text
      file, but a security
      problem that exists within the script and the PHP ini file has been
      set to off with register globals....

      Comment

      • Jerry Stuckle

        #4
        Re: Windows to Unix text doc parsing problem

        programming wrote:
        On Apr 5, 1:46 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        >programming wrote:
        >>Hi all,
        >>i have been having trouble with a login script that works on my
        >>windows machine, however when i upload it to the Unix server through
        >>VPN, the same script won't work! It won't parse member.txt properly i
        >>think. The password and usernames i am using are at the bottom of this
        >>post.
        >>Each time i go to login on the unix server, it clears the username and
        >>password field. I have been attempting to solve the problem, but have
        >>been baffled to see why there is such an issue. I have taken out the
        >>HTML, and just given you the PHP script that i am running. The
        >>original programming was done on Unix!.
        >>My question to people on here is why does my script run on Windows and
        >>not on Unix? How can i fix the problem?
        >>Here is the source code i have been looking at:
        >>\-------------------------------------------------------------------------------------------------------------------------------------------------------------------
        >><?
        >>session_start ();
        >>if ($userid && $password)
        >>{
        >>//listf stores a reference to the file itself
        >>$listf=fopen( "username/member.txt","r" );
        >>#read the file
        >>list($duserid ,$dpassword)=fg etcsv($listf,10 24,"|");
        >>$duserid=trim ($duserid);
        >>$dpassword=tr im($dpassword);
        >> //keep reading until the end of the file is reached
        >> while(!feof($li stf)){
        >> if(($userid==$d userid)&&($pass word==$dpasswor d))
        >> {
        >> $_SESSION['valid_user']=$userid;
        >> break;
        >> }
        >> list($duserid,$ dpassword)=fget csv($listf,1024 ,"|");
        >> $duserid=trim($ duserid);
        >> $dpassword=trim ($dpassword);
        >> }
        >> fclose($listf);
        >>}
        >>?>
        >>------HTML-------
        >><?
        >>$tempstr=$_SE SSION['valid_user'];
        >>if (isset($_SESSIO N['valid_user'])){
        >> echo "You are logged in as: $tempstr<br>";
        >> echo "<a href=\"admin_ho me.php\">Admin Home</a><br>";
        >>}
        >>else{
        >> if (isset($userid) ) {
        >> // if they've tried and failed to log in
        >> echo "Could not log you in";
        >>}
        >>else{
        >> // they have not tried to log in yet or have logged out
        >> echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
        >>border=0 valign=\"top\" align=\"center\ ">";
        >> echo "<tr><td>Yo u are not logged in.<br></td>";
        >> echo "</table>";
        >>}
        >> // provide form to log in
        >> echo "<form method=post action=\"login. php\">";
        >> echo "<table border=0 width=\"600\" cellspacing=0 cellpadding=0
        >>border=0 valign=\"top\" align=\"center\ ">";
        >> echo "<tr><td>Userid :</td>";
        >> echo "<td><input type=text name=userid></td></tr>";
        >> echo "<tr><td>Passwo rd:</td>";
        >> echo "<td><input type=password name=password></td></tr>";
        >> echo "<tr><td colspan=2 align=right>";
        >> echo "<input type=submit value=\"Log in\">";
        >> //echo "<tr><td colspan=1 align=center>";
        >> echo "<input type=reset value=\"Reset\" ></td></tr>";
        >> echo "</table></form>";
        >>}
        >>?>
        >>--------------------------------------------------------------------------------------------------------------------------------------------------------------------
        >>Here is the Windows copy of the member.txt that only works with ASCII
        >>block terminator at the end of the file:
        >>------------------------------------------------------------------------------------------------------------------------------------------------------------------
        >>admin|1234|Sc hool|Computing| bhk...@utas.edu .au|University of Tasmania|
        >>1
        >>bhkang|abcd12 34|Kang|ByeongH o|bhk...@utas.e du.au|Computing |2
        >>--------------------------------------------------------------------------------------------------------------------------------------------------------------------
        >>Cheers,
        >>Peri.
        >Peri,
        >>
        >You have register_global s enabled on your Windows machine (VERY BAD) and
        >disabled on your Unix machine (VERY GOOD).
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstuck...@attg lobal.net
        >============== ====
        >
        Ok Jerry thanks for the advice, it is strange that most of the code i
        have adapted here comes from some tutorial work i have been doing, and
        that
        it suppose to be tested initially on the Unix server. So, you are
        telling me that the problem is not in the program reading the text
        file, but a security
        problem that exists within the script and the PHP ini file has been
        set to off with register globals....
        >
        Yep. But it has nothing to do with Unix vs. Windows. register_global s
        used to default to on (in fact in early releases of PHP you didn't have
        a choice). More recent versions default to off, and it's the best way
        to have it.

        And there are a lot of bad PHP tutorials on the web - more than any
        other language I've seen. Seems anyone with 2 weeks of PHP experience
        (and no prior programming) considers them selves "expert" enough to
        write tutorials.


        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Tim Van Wassenhove

          #5
          Re: Windows to Unix text doc parsing problem

          programming schreef:
          i have been having trouble
          <?
          While debugging it can be helpfull to start your script with the
          following (or make sure your php configuration has the same settings)

          ini_set('displa y_errors', true);
          ini_set('error_ reporting', E_ALL);
          if ($userid && $password)
          As already mentionned, $userid and $password are probably undefined at
          this point, and you should test if $_POST['userid'] and
          $_POST['password'] exist...
          $listf=fopen("u sername/member.txt","r" );
          Since you're using a relative path, you may want to check your
          include_path setting too...


          --
          Tim Van Wassenhove <url:http://www.timvw.be/>

          Comment

          • R. Rajesh Jeba Anbiah

            #6
            |OT| Re: Windows to Unix text doc parsing problem

            On Apr 6, 7:40 pm, Tim Van Wassenhove <t...@users.sou rceforge.net>
            wrote:
            <snip>
            While debugging it can be helpfull to start your script with the
            following (or make sure your php configuration has the same settings)
            >
            ini_set('displa y_errors', true);
            ini_set('error_ reporting', E_ALL);
            <snip>

            Back to PHP again?

            --
            <?php echo 'Just another PHP saint'; ?>
            Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

            Comment

            • Tim Van Wassenhove

              #7
              Re: |OT| Re: Windows to Unix text doc parsing problem

              R. Rajesh Jeba Anbiah schreef:
              Back to PHP again?
              Never left ;)

              (Just a bit busy looking at the 'others' (mainly asp.net) how they do
              webdevelopment ;)


              --
              Tim Van Wassenhove <url:http://www.timvw.be/>

              Comment

              • R. Rajesh Jeba Anbiah

                #8
                Re: |OT| Re: Windows to Unix text doc parsing problem

                On Apr 7, 12:33 pm, Tim Van Wassenhove <t...@users.sou rceforge.net>
                wrote:
                R.RajeshJebaAnb iahschreef:
                >
                Back to PHP again?
                >
                Never left ;)
                >
                (Just a bit busy looking at the 'others' (mainly asp.net) how they do
                webdevelopment ;)
                Nice to know:) Apologies for the late response. I'm too busy
                lurking CakePHP:)

                --
                <?php echo 'Just another PHP saint'; ?>
                Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

                Comment

                Working...