The pfSense Store

Author Topic: Is it possible for me to display a users IP address on the login page??  (Read 20735 times)

0 Members and 1 Guest are viewing this topic.

Offline Tram

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Is it possible for me to display a users IP address assigned to them by the pfsense DHCP server on the login page?? i want to do this so that when the view bandwidthd which is a link on the page they know which IP is theres and view there statistics.

I know the login page is a basic html page but it says something in the captive portal file manager about using php but i don't know how to do it.

Thanks

Offline JorgeAldoBR

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
put this where you want the ip to appear :

<?php echo getenv('REMOTE_ADDR'); ?>



Offline jeroen234

  • Sr. Member
  • ****
  • Posts: 505
  • Karma: +0/-0
    • View Profile
upload this page as youre pfsense portal page

Code: [Select]
HTML>
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="1";URL="$PORTAL_ACTION$p.php?portal_action=$PORTAL_ACTION$&portal_redirurl=$PORTAL_REDIRURL$">
</HEAD>

<BODY>
</BODY>
</HTML>

now it will send you to p.php afther 1 sec

p.php

Code: [Select]
<?
echo "<br><br><br>";
echo "Welkom youre ipadress = ";
echo getenv('REMOTE_ADDR');
echo "<br><br>";
?>
<table>
<form method="post" action="<?php echo $_GET["portal_action"]; ?>">
<tr><td><h3>usernaam</h3></td><td><input name="auth_user" type="text"></td></tr>
<tr><td><h3>wachtwoord </h3></td><td><input name="auth_pass" type="password"></td></tr>
   <input name="redirurl" type="hidden" value="<?php echo $_GET["portal_redirurl"]; ?>">
   <tr><td><input name="accept" type="submit" value="Continue"></td><td></td></tr>
</form>
</table>


« Last Edit: May 22, 2007, 01:10:03 am by jeroen234 »

Offline JorgeAldoBR

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Why my code doesnt work ? (I did not try it, but i presume now that it doesnt work)

Offline jeroen234

  • Sr. Member
  • ****
  • Posts: 505
  • Karma: +0/-0
    • View Profile
ehmm i don't see code from you ??

Offline Cry Havok

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2792
  • Karma: +0/-0
  • Backup: n. What you should have done yesterday.
    • View Profile
ehmm i don't see code from you ??

Second post in this thread:

put this where you want the ip to appear :

<?php echo getenv('REMOTE_ADDR'); ?>

It wasn't inside a code block though, so not obvious :)
If you're planning on PMing me to ask me to look at a thread, or for individual support, don't.

Offline jeroen234

  • Sr. Member
  • ****
  • Posts: 505
  • Karma: +0/-0
    • View Profile
if you put that in a php page then it will work
in the example php portal page (3 post in topic) i have include it

Offline JorgeAldoBR

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Thank you.

Offline alexander007

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Is it possible for me to display a users IP address on the login page??
« Reply #8 on: August 08, 2007, 11:01:43 am »
that dont work for me...it keeps reloading...

index.html
Code: [Select]
<HTML>
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="1";URL="$PORTAL_ACTION$captiveportal-portal.php?portal_action=$PORTAL_ACTION$&portal_redirurl=$PORTAL_REDIRURL$">
</HEAD>
<BODY>
Loading...
</BODY>
</HTML>

captiveportal-portal.php
Code: [Select]
<form method="post" action="<?php echo $_GET["portal_action"]; ?>">
              <div align="left">
                <table width="200" border="0">
                  <tr>
                    <td><div align="right"><strong>Usuario:</strong></div></td>
                      <td><label>
                        <input name="auth_user" type="text" size="20" />
                      </label></td>
                      <td><strong>@uprrp.edu</strong></td>
                    </tr>
                  <tr>
                    <td><div align="right"><strong>Contraseņa:</strong></div></td>
                      <td><label>
                        <input name="auth_pass" type="password" size="20" />
                      </label></td>
                      <td>&nbsp;</td>
                    </tr>
                  <tr>
                    <td>&nbsp;</td>
                      <td><label>
                        <div align="center">
                          <input name="redirurl" value="<?php echo $_GET["portal_redirurl"]; ?>" type="hidden">
                          <input type="submit" name="button" id="button" value="Conectar" />
                        </div>
                      </label></td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </div>
            </form>

whats wrong?

Offline alexander007

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Is it possible for me to display a users IP address on the login page??
« Reply #9 on: August 09, 2007, 07:28:53 pm »
I found the problem ;D

Offline Gertjan

  • Sr. Member
  • ****
  • Posts: 337
  • Karma: +0/-0
    • View Profile
Re: Is it possible for me to display a users IP address on the login page??
« Reply #10 on: August 10, 2007, 04:13:49 am »
I found the problem ;D
What was it  ? :D

Do we have to supose that somethings is wrong with your posts ?

Offline docwho76

  • Jr. Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Is it possible for me to display a users IP address on the login page??
« Reply #11 on: August 24, 2008, 02:23:03 pm »
Since no one seems to bother with documenting this, and I just finished banging my head against this issue where the redirect just keeps reloading itself and not going to the page specified. To fix it you MUST do the quotation marks in the META HTTP-EQUIV line correctly:

Bad
Code: [Select]
<META HTTP-EQUIV="REFRESH" CONTENT="1";URL="/captiveportal-portal.php">
Good
Code: [Select]
<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=/captiveportal-lclogin.php">
Hope this saves other people torment anguish and wasted time Googling.

I found the problem ;D
What was it  ? :D

Do we have to supose that somethings is wrong with your posts ?